diff --git a/changelog/@unreleased/pr-2421.v2.yml b/changelog/@unreleased/pr-2421.v2.yml new file mode 100644 index 000000000..74f85be0e --- /dev/null +++ b/changelog/@unreleased/pr-2421.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: 'remove bounds check on input ''long'' values into ''alias: double''' + links: + - https://github.com/palantir/conjure-java/pull/2421 diff --git a/conjure-java-core/src/integrationInput/java/com/palantir/product/AliasedDouble.java b/conjure-java-core/src/integrationInput/java/com/palantir/product/AliasedDouble.java index ce7dd6395..422c64784 100644 --- a/conjure-java-core/src/integrationInput/java/com/palantir/product/AliasedDouble.java +++ b/conjure-java-core/src/integrationInput/java/com/palantir/product/AliasedDouble.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -import com.palantir.conjure.java.lib.SafeLong; import java.math.BigDecimal; import javax.annotation.Nullable; import javax.annotation.processing.Generated; @@ -55,8 +54,7 @@ public static AliasedDouble of(double value) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static AliasedDouble of(long value) { - long safeValue = SafeLong.of(value).longValue(); - return new AliasedDouble((double) safeValue); + return new AliasedDouble((double) value); } @JsonCreator(mode = JsonCreator.Mode.DELEGATING) diff --git a/conjure-java-core/src/integrationInput/java/com/palantir/product/DoubleAliasExample.java b/conjure-java-core/src/integrationInput/java/com/palantir/product/DoubleAliasExample.java index b4f4bda83..c5fe9d5dd 100644 --- a/conjure-java-core/src/integrationInput/java/com/palantir/product/DoubleAliasExample.java +++ b/conjure-java-core/src/integrationInput/java/com/palantir/product/DoubleAliasExample.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -import com.palantir.conjure.java.lib.SafeLong; import java.math.BigDecimal; import javax.annotation.Nullable; import javax.annotation.processing.Generated; @@ -55,8 +54,7 @@ public static DoubleAliasExample of(double value) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static DoubleAliasExample of(long value) { - long safeValue = SafeLong.of(value).longValue(); - return new DoubleAliasExample((double) safeValue); + return new DoubleAliasExample((double) value); } @JsonCreator(mode = JsonCreator.Mode.DELEGATING) diff --git a/conjure-java-core/src/integrationInput/java/com/palantir/product/SafeDoubleAliasExample.java b/conjure-java-core/src/integrationInput/java/com/palantir/product/SafeDoubleAliasExample.java index decb20142..64607d35a 100644 --- a/conjure-java-core/src/integrationInput/java/com/palantir/product/SafeDoubleAliasExample.java +++ b/conjure-java-core/src/integrationInput/java/com/palantir/product/SafeDoubleAliasExample.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -import com.palantir.conjure.java.lib.SafeLong; import com.palantir.logsafe.Safe; import java.math.BigDecimal; import javax.annotation.Nullable; @@ -58,8 +57,7 @@ public static SafeDoubleAliasExample of(@Safe double value) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static SafeDoubleAliasExample of(@Safe long value) { - long safeValue = SafeLong.of(value).longValue(); - return new SafeDoubleAliasExample((double) safeValue); + return new SafeDoubleAliasExample((double) value); } @JsonCreator(mode = JsonCreator.Mode.DELEGATING) diff --git a/conjure-java-core/src/integrationInput/java/test/prefix/com/palantir/product/DoubleAliasExample.java b/conjure-java-core/src/integrationInput/java/test/prefix/com/palantir/product/DoubleAliasExample.java index c5d2cfa7d..dbf9e3f77 100644 --- a/conjure-java-core/src/integrationInput/java/test/prefix/com/palantir/product/DoubleAliasExample.java +++ b/conjure-java-core/src/integrationInput/java/test/prefix/com/palantir/product/DoubleAliasExample.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -import com.palantir.conjure.java.lib.SafeLong; import java.math.BigDecimal; import javax.annotation.Nullable; import javax.annotation.processing.Generated; @@ -55,8 +54,7 @@ public static DoubleAliasExample of(double value) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static DoubleAliasExample of(long value) { - long safeValue = SafeLong.of(value).longValue(); - return new DoubleAliasExample((double) safeValue); + return new DoubleAliasExample((double) value); } @JsonCreator(mode = JsonCreator.Mode.DELEGATING) diff --git a/conjure-java-core/src/integrationInput/java/test/prefix/com/palantir/product/SafeDoubleAliasExample.java b/conjure-java-core/src/integrationInput/java/test/prefix/com/palantir/product/SafeDoubleAliasExample.java index 36ccd00dc..712489f9e 100644 --- a/conjure-java-core/src/integrationInput/java/test/prefix/com/palantir/product/SafeDoubleAliasExample.java +++ b/conjure-java-core/src/integrationInput/java/test/prefix/com/palantir/product/SafeDoubleAliasExample.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -import com.palantir.conjure.java.lib.SafeLong; import com.palantir.logsafe.Safe; import java.math.BigDecimal; import javax.annotation.Nullable; @@ -58,8 +57,7 @@ public static SafeDoubleAliasExample of(@Safe double value) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static SafeDoubleAliasExample of(@Safe long value) { - long safeValue = SafeLong.of(value).longValue(); - return new SafeDoubleAliasExample((double) safeValue); + return new SafeDoubleAliasExample((double) value); } @JsonCreator(mode = JsonCreator.Mode.DELEGATING) diff --git a/conjure-java-core/src/main/java/com/palantir/conjure/java/types/AliasGenerator.java b/conjure-java-core/src/main/java/com/palantir/conjure/java/types/AliasGenerator.java index 662cdfabb..6b54069d7 100644 --- a/conjure-java-core/src/main/java/com/palantir/conjure/java/types/AliasGenerator.java +++ b/conjure-java-core/src/main/java/com/palantir/conjure/java/types/AliasGenerator.java @@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableList; import com.palantir.conjure.java.ConjureAnnotations; import com.palantir.conjure.java.Options; -import com.palantir.conjure.java.lib.SafeLong; import com.palantir.conjure.java.util.Javadoc; import com.palantir.conjure.java.util.Packages; import com.palantir.conjure.java.util.Primitives; @@ -148,8 +147,7 @@ public static JavaFile generateAliasType( if (isAliasOfDouble(typeDef)) { CodeBlock longCastCodeBlock = CodeBlock.builder() - .addStatement("long safeValue = $T.of(value).longValue()", SafeLong.class) - .addStatement("return new $T((double) safeValue)", thisClass) + .addStatement("return new $T((double) value)", thisClass) .build(); CodeBlock intCastCodeBlock = CodeBlock.builder()