package checkdep.util;

import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import com.google.common.collect.ImmutableMap;
import lombok.NonNull;
import lombok.Value;

//@Value(staticConstructor = "of") なぜかIntelliJだとエラーになるのでof()を手動化
@Value
public class ReadOnlyMap<K, V> {

  public static <K, V> ReadOnlyMap<K, V> of(ImmutableMap<K, V> map) {
    return new ReadOnlyMap<>(map);
  }

  public static <K, V> ReadOnlyMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
    return of(ImmutableMap.copyOf(map));
  }

  @NonNull
  private final ImmutableMap<K, V> map;

  public Optional<V> get(@NonNull K key) {
    return Optional.ofNullable(map.get(key));
  }

  public Set<K> keySet() {
    return map.keySet();
  }

  public Collection<V> values() {
    return map.values();
  }

  public Set<Map.Entry<K, V>> entrySet() {
    return map.entrySet();
  }

  @Override
  public String toString() {
    return map.toString();
  }
}

@@ -375,27 +375,27 @@
 leMap%3CK, V%3E 
-map
+raw
 ) %7B%0A    retu
@@ -415,19 +415,19 @@
 lyMap%3C%3E(
-map
+raw
 );%0A  %7D%0A%0A
@@ -504,19 +504,19 @@
 ends V%3E 
-map
+raw
 ) %7B%0A    
@@ -545,19 +545,19 @@
 .copyOf(
-map
+raw
 ));%0A  %7D%0A
@@ -603,19 +603,19 @@
 p%3CK, V%3E 
-map
+raw
 ;%0A%0A  pub
@@ -683,19 +683,19 @@
 ullable(
-map
+raw
 .get(key
@@ -741,19 +741,19 @@
  return 
-map
+raw
 .keySet(
@@ -805,19 +805,19 @@
  return 
-map
+raw
 .values(
@@ -878,19 +878,19 @@
  return 
-map
+raw
 .entrySe
@@ -955,11 +955,11 @@
 urn 
-map
+raw
 .toS

rename field variable