File tree Expand file tree Collapse file tree 4 files changed +16
-13
lines changed
Expand file tree Collapse file tree 4 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ public Object parseValue(Object input) {
3131 @ Override
3232 public Object parseLiteral (Object input ) {
3333 if (!(input instanceof IntValue )) return null ;
34- return ((IntValue ) input ).getValue ();
34+ return ((IntValue ) input ).getValue (). intValueExact () ;
3535 }
3636 });
3737
@@ -60,7 +60,7 @@ public Object parseLiteral(Object input) {
6060 if (input instanceof StringValue ) {
6161 return Long .parseLong (((StringValue ) input ).getValue ());
6262 } else if (input instanceof IntValue ) {
63- return ((IntValue ) input ).getValue ();
63+ return ((IntValue ) input ).getValue (). longValueExact () ;
6464 }
6565 return null ;
6666 }
Original file line number Diff line number Diff line change 11package graphql .language ;
22
33
4+ import java .math .BigInteger ;
45import java .util .ArrayList ;
56import java .util .List ;
67
78public class IntValue extends AbstractNode implements Value {
89
9- private int value ;
10+ private BigInteger value ;
1011
11- public IntValue (int value ) {
12+ public IntValue (BigInteger value ) {
1213 this .value = value ;
1314 }
1415
15- public int getValue () {
16+ public BigInteger getValue () {
1617 return value ;
1718 }
1819
19- public void setValue (int value ) {
20+ public void setValue (BigInteger value ) {
2021 this .value = value ;
2122 }
2223
@@ -30,9 +31,9 @@ public boolean isEqualTo(Node o) {
3031 if (this == o ) return true ;
3132 if (o == null || getClass () != o .getClass ()) return false ;
3233
33- IntValue intValue = (IntValue ) o ;
34+ IntValue that = (IntValue ) o ;
3435
35- return value == intValue . value ;
36+ return !( value != null ? ! value . equals ( that . value ) : that . value != null ) ;
3637
3738 }
3839
Original file line number Diff line number Diff line change 88import org .antlr .v4 .runtime .ParserRuleContext ;
99
1010import java .math .BigDecimal ;
11+ import java .math .BigInteger ;
1112import java .util .ArrayDeque ;
1213import java .util .Deque ;
1314
@@ -321,7 +322,7 @@ public Void visitDirective(GraphqlParser.DirectiveContext ctx) {
321322
322323 private Value getValue (GraphqlParser .ValueWithVariableContext ctx ) {
323324 if (ctx .IntValue () != null ) {
324- IntValue intValue = new IntValue (Integer . parseInt (ctx .IntValue ().getText ()));
325+ IntValue intValue = new IntValue (new BigInteger (ctx .IntValue ().getText ()));
325326 newNode (intValue , ctx );
326327 return intValue ;
327328 } else if (ctx .FloatValue () != null ) {
@@ -366,7 +367,7 @@ private Value getValue(GraphqlParser.ValueWithVariableContext ctx) {
366367
367368 private Value getValue (GraphqlParser .ValueContext ctx ) {
368369 if (ctx .IntValue () != null ) {
369- IntValue intValue = new IntValue (Integer . parseInt (ctx .IntValue ().getText ()));
370+ IntValue intValue = new IntValue (new BigInteger (ctx .IntValue ().getText ()));
370371 newNode (intValue , ctx );
371372 return intValue ;
372373 } else if (ctx .FloatValue () != null ) {
Original file line number Diff line number Diff line change @@ -56,9 +56,10 @@ class ScalarsTest extends Specification {
5656 Scalars.GraphQLLong . getCoercing(). parseLiteral(literal) == result
5757
5858 where :
59- literal | result
60- new StringValue (" 42" ) | 42
61- new IntValue (42 ) | 42
59+ literal | result
60+ new StringValue (" 42" ) | 42
61+ new IntValue (42 ) | 42
62+ new IntValue (42345784398534785l ) | 42345784398534785l
6263 }
6364
6465
You can’t perform that action at this time.
0 commit comments