Fix compat with older guava versions

This commit is contained in:
Luck 2016-12-03 13:55:51 +00:00
parent 83b0f62d59
commit cd7b3b4f6e
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 18 additions and 10 deletions

View File

@ -30,7 +30,6 @@ import com.google.common.collect.Multimap;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* An immutable implementation of {@link ContextSet}. * An immutable implementation of {@link ContextSet}.
@ -71,13 +70,12 @@ public final class ImmutableContextSet implements ContextSet {
throw new NullPointerException("map"); throw new NullPointerException("map");
} }
return new ImmutableContextSet(ImmutableMultimap.copyOf( ImmutableMultimap.Builder<String, String> b = ImmutableMultimap.builder();
map.entrySet().stream() for (Map.Entry<String, String> e : map.entrySet()) {
.collect(Collectors.toMap( b.put(e.getKey(), e.getValue());
e -> e.getKey().toLowerCase(), }
Map.Entry::getValue
)).entrySet() return new ImmutableContextSet(b.build());
));
} }
/** /**
@ -160,7 +158,12 @@ public final class ImmutableContextSet implements ContextSet {
@Override @Override
public Map<String, String> toMap() { public Map<String, String> toMap() {
return ImmutableMap.copyOf(map.entries()); ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
for (Map.Entry<String, String> e : map.entries()) {
m.put(e.getKey(), e.getValue());
}
return m.build();
} }
@Override @Override

View File

@ -168,7 +168,12 @@ public final class MutableContextSet implements ContextSet {
@Override @Override
public Map<String, String> toMap() { public Map<String, String> toMap() {
return ImmutableMap.copyOf(map.entries()); ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
for (Map.Entry<String, String> e : map.entries()) {
m.put(e.getKey(), e.getValue());
}
return m.build();
} }
@Override @Override