Skip to content

Commit

Permalink
{#191] Removed uses of guava
Browse files Browse the repository at this point in the history
  • Loading branch information
andylowry committed Aug 22, 2018
1 parent 6d22992 commit b970421
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
Expand All @@ -24,8 +27,6 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ShortNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.reprezen.jsonoverlay.BooleanOverlay;
import com.reprezen.jsonoverlay.IntegerOverlay;
import com.reprezen.jsonoverlay.JsonOverlay;
Expand Down Expand Up @@ -54,7 +55,7 @@ public static void checkJsonType(Overlay<?> value, ValidationResults results) {
}
}

private static Multimap<Class<?>, Class<? extends JsonNode>> allowedJsonTypes = null;
private static Map<Class<?>, List<Class<? extends JsonNode>>> allowedJsonTypes = null;

private static Collection<Class<? extends JsonNode>> getAllowedJsonTypes(Overlay<?> value) {
if (allowedJsonTypes == null) {
Expand All @@ -66,17 +67,16 @@ private static Collection<Class<? extends JsonNode>> getAllowedJsonTypes(Overlay
}

private static void createAllowedJsonTypes() {
Multimap<Class<?>, Class<? extends JsonNode>> types = ArrayListMultimap
.<Class<?>, Class<? extends JsonNode>>create();
types.put(StringOverlay.class, TextNode.class);
types.put(BooleanOverlay.class, BooleanNode.class);
types.putAll(IntegerOverlay.class, Arrays.asList(IntNode.class, ShortNode.class, BigIntegerNode.class));
types.put(NumberOverlay.class, NumericNode.class);
types.putAll(PrimitiveOverlay.class, Arrays.asList(TextNode.class, NumericNode.class, BooleanNode.class));
types.put(ObjectOverlay.class, JsonNode.class);
types.put(MapOverlay.class, ObjectNode.class);
types.put(ListOverlay.class, ArrayNode.class);
types.put(PropertiesOverlay.class, ObjectNode.class);
Map<Class<?>, List<Class<? extends JsonNode>>> types = new HashMap<>();
types.put(StringOverlay.class, Arrays.asList(TextNode.class));
types.put(BooleanOverlay.class, Arrays.asList(BooleanNode.class));
types.put(IntegerOverlay.class, Arrays.asList(IntNode.class, ShortNode.class, BigIntegerNode.class));
types.put(NumberOverlay.class, Arrays.asList(NumericNode.class));
types.put(PrimitiveOverlay.class, Arrays.asList(TextNode.class, NumericNode.class, BooleanNode.class));
types.put(ObjectOverlay.class, Arrays.asList(JsonNode.class));
types.put(MapOverlay.class, Arrays.asList(ObjectNode.class));
types.put(ListOverlay.class, Arrays.asList(ArrayNode.class));
types.put(PropertiesOverlay.class, Arrays.asList(ObjectNode.class));
allowedJsonTypes = types;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

import com.google.common.collect.Maps;

public class NumericUtils {
public static boolean isNumeric(Object obj) {
return NumericType.of(obj) != null;
Expand Down Expand Up @@ -162,7 +161,7 @@ private NumericType(Class<? extends Number> cls) {

private void register(Class<? extends Number> cls, NumericType type) {
if (NumericType.types == null)
NumericType.types = Maps.newHashMap();
NumericType.types = new HashMap<>();
types.put(cls, type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import static com.reprezen.kaizen.oasparser.val.ValidationResults.Severity.NONE;
import static com.reprezen.kaizen.oasparser.val.ValidationResults.Severity.WARNING;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.google.common.collect.Lists;
import com.reprezen.jsonoverlay.Overlay;
import com.reprezen.jsonoverlay.PositionInfo;

Expand Down Expand Up @@ -82,7 +82,7 @@ public boolean ge(Severity other) {
}
};

List<ValidationItem> items = Lists.newArrayList();
List<ValidationItem> items = new ArrayList<>();

public <V> void addInfo(String msg, Overlay<V> context) {
items.add(new ValidationItem(INFO, msg, context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand All @@ -15,7 +16,6 @@
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;

import com.google.common.collect.Sets;
import com.reprezen.jsonoverlay.ListOverlay;
import com.reprezen.jsonoverlay.MapOverlay;
import com.reprezen.jsonoverlay.Overlay;
Expand Down Expand Up @@ -237,7 +237,7 @@ private <X> void checkListNotEmpty(Overlay<List<X>> list, boolean nonEmpty) {
private <X> void checkListUnique(Overlay<List<X>> list, boolean unique) {
if (unique) {
ListOverlay<X> listOverlay = Overlay.getListOverlay(list);
Set<X> seen = Sets.newHashSet();
Set<X> seen = new HashSet<>();
for (int i = 0; i < listOverlay.size(); i++) {
X item = listOverlay.get(i);
if (seen.contains(item)) {
Expand Down Expand Up @@ -280,7 +280,7 @@ private <X> void checkMapNotEmpty(Overlay<Map<String, X>> list, boolean nonEmpty
private <X> void checkMapUnique(Overlay<Map<String, X>> map, boolean unique) {
if (unique) {
MapOverlay<X> mapOverlay = Overlay.getMapOverlay(map);
Set<X> seen = Sets.newHashSet();
Set<X> seen = new HashSet<>();
for (String key : mapOverlay.keySet()) {
X value = mapOverlay.get(key);
if (seen.contains(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import static com.reprezen.kaizen.oasparser.val.Messages.m;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.google.common.collect.Maps;
import com.reprezen.jsonoverlay.Overlay;
import com.reprezen.kaizen.oasparser.model3.Link;
import com.reprezen.kaizen.oasparser.model3.OpenApi3;
Expand Down Expand Up @@ -128,7 +128,7 @@ private String getRelativePath(String operationRef, ValidationResults results) {
}

private Map<String, Integer> getParamNameCounts(Collection<? extends Parameter> parameters) {
Map<String, Integer> counts = Maps.newHashMap();
Map<String, Integer> counts = new HashMap<>();
for (Parameter parameter : parameters) {
String name = parameter.getName();
if (counts.containsKey(name)) {
Expand Down

0 comments on commit b970421

Please sign in to comment.