diff --git a/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureCollections.java b/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureCollections.java index 529891bf6..80870867c 100644 --- a/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureCollections.java +++ b/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureCollections.java @@ -171,11 +171,7 @@ public static List newNonNullDoubleList(Iterable iterable) { // This method modifies a list that can't handle nulls. Do not use this unless the nonNullCollections flag is set public static void addAllToDoubleList(Collection addTo, double[] elementsToAdd) { - if (addTo instanceof ConjureDoubleList) { - ((ConjureDoubleList) addTo).addAll(elementsToAdd); - } else { - addAll(addTo, () -> Arrays.stream(elementsToAdd).iterator()); - } + addAll(addTo, () -> Arrays.stream(elementsToAdd).iterator()); } // This method returns a list that can't handle nulls. Do not use this unless the nonNullCollections flag is set @@ -198,11 +194,7 @@ public static List newNonNullIntegerList(Iterable iterable) { // This method modifies a list that can't handle nulls. Do not use this unless the nonNullCollections flag is set public static void addAllToIntegerList(Collection addTo, int[] elementsToAdd) { - if (addTo instanceof ConjureIntegerList) { - ((ConjureIntegerList) addTo).addAll(elementsToAdd); - } else { - addAll(addTo, () -> Arrays.stream(elementsToAdd).iterator()); - } + addAll(addTo, () -> Arrays.stream(elementsToAdd).iterator()); } /** @@ -240,10 +232,6 @@ public static List newNonNullSafeLongList(Iterable iterable) // This method modifies a list that can't handle nulls. Do not use this unless the nonNullCollections flag is set public static void addAllToSafeLongList(Collection addTo, long[] elementsToAdd) { - if (addTo instanceof ConjureSafeLongList) { - ((ConjureSafeLongList) addTo).addAll(elementsToAdd); - } else { - addAll(addTo, Arrays.stream(elementsToAdd).boxed().map(SafeLong::of).toList()); - } + addAll(addTo, Arrays.stream(elementsToAdd).boxed().map(SafeLong::of).toList()); } } diff --git a/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureDoubleList.java b/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureDoubleList.java index 2e3ac9f5c..87a1eceb5 100644 --- a/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureDoubleList.java +++ b/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureDoubleList.java @@ -16,7 +16,6 @@ package com.palantir.conjure.java.lib.internal; -import com.fasterxml.jackson.annotation.JsonValue; import java.util.AbstractList; import java.util.Collection; import java.util.RandomAccess; @@ -56,10 +55,6 @@ public boolean addAll(int index, Collection collection) { return delegate.addAllAtIndex(index, target); } - public void addAll(double... source) { - this.delegate.addAll(source); - } - @Override public Double remove(int index) { return delegate.removeAtIndex(index); @@ -74,15 +69,4 @@ public void clear() { public Double set(int index, Double element) { return delegate.set(index, element); } - - public ConjureDoubleList asUnmodifiable() { - return new ConjureDoubleList(delegate.asUnmodifiable()); - } - - // Cannot be named 'toArray' as that conflicts with the #toArray in AbstractList - // This is a serialization optimization that avoids boxing, but does copy - @JsonValue - double[] jacksonSerialize() { - return delegate.toArray(); - } } diff --git a/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureIntegerList.java b/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureIntegerList.java index 48b476fec..7f2f3715b 100644 --- a/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureIntegerList.java +++ b/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureIntegerList.java @@ -16,7 +16,6 @@ package com.palantir.conjure.java.lib.internal; -import com.fasterxml.jackson.annotation.JsonValue; import java.util.AbstractList; import java.util.Collection; import java.util.RandomAccess; @@ -56,10 +55,6 @@ public boolean addAll(int index, Collection collection) { return delegate.addAllAtIndex(index, target); } - public void addAll(int... source) { - this.delegate.addAll(source); - } - @Override public Integer remove(int index) { return delegate.removeAtIndex(index); @@ -74,15 +69,4 @@ public void clear() { public Integer set(int index, Integer element) { return delegate.set(index, element); } - - public ConjureIntegerList asUnmodifiable() { - return new ConjureIntegerList(delegate.asUnmodifiable()); - } - - // Cannot be named 'toArray' as that conflicts with the #toArray in AbstractList - // This is a serialization optimization that avoids boxing, but does copy - @JsonValue - int[] jacksonSerialize() { - return delegate.toArray(); - } } diff --git a/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureSafeLongList.java b/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureSafeLongList.java index 03dd07176..2e77c8d07 100644 --- a/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureSafeLongList.java +++ b/conjure-lib/src/main/java/com/palantir/conjure/java/lib/internal/ConjureSafeLongList.java @@ -16,9 +16,7 @@ package com.palantir.conjure.java.lib.internal; -import com.fasterxml.jackson.annotation.JsonValue; import com.palantir.conjure.java.lib.SafeLong; -import com.palantir.logsafe.Preconditions; import java.util.AbstractList; import java.util.Collection; import java.util.RandomAccess; @@ -58,18 +56,6 @@ public boolean addAll(int index, Collection collection) { return delegate.addAllAtIndex(index, target); } - public void addAll(long... source) { - for (long value : source) { - // Doesn't use SafeLong creation because this causes unnecessary boxing - // Mostly copied from SafeLong - Preconditions.checkArgument( - SafeLong.MIN_VALUE.longValue() <= value && value <= SafeLong.MAX_VALUE.longValue(), - "number must be safely representable in javascript i.e. " - + "lie between -9007199254740991 and 9007199254740991"); - } - this.delegate.addAll(source); - } - @Override public SafeLong remove(int index) { return SafeLong.of(delegate.removeAtIndex(index)); @@ -84,15 +70,4 @@ public void clear() { public SafeLong set(int index, SafeLong element) { return SafeLong.of(delegate.set(index, element.longValue())); } - - public ConjureSafeLongList asUnmodifiable() { - return new ConjureSafeLongList(delegate.asUnmodifiable()); - } - - // Cannot be named 'toArray' as that conflicts with the #toArray in AbstractList - // This is a serialization optimization that avoids boxing, but does copy - @JsonValue - long[] jacksonSerialize() { - return delegate.toArray(); - } }