@Override public Double parseLiteral(Object input) { if (input instanceof IntValue) { return ((IntValue) input).getValue().doubleValue(); } else if (input instanceof FloatValue) { return ((FloatValue) input).getValue().doubleValue(); } else { throw new CoercingParseLiteralException( "Expected AST type 'IntValue' or 'FloatValue' but was '" + typeName(input) + "'." ); } } });
@Override public IntValue deepCopy() { return new IntValue(value, getSourceLocation(), getComments(), IgnoredChars.EMPTY); }
private static Value handleNumber(String stringValue) { if (stringValue.matches("^[0-9]+$")) { return IntValue.newIntValue().value(new BigInteger(stringValue)).build(); } else { return FloatValue.newFloatValue().value(new BigDecimal(stringValue)).build(); } }
private Builder(IntValue existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.value = existing.getValue(); }
public IntValue build() { IntValue intValue = new IntValue(value, sourceLocation, comments, ignoredChars); return intValue; } }
@Override public TraversalControl visitIntValue(IntValue node, TraverserContext<Node> context) { return changeNode(context, node.transform(builder -> builder.value(BigInteger.ZERO))); }
private Builder(IntValue existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.value = existing.getValue(); }
public IntValue build() { IntValue intValue = new IntValue(value, sourceLocation, comments, ignoredChars); return intValue; } }
@Override public TraversalControl visitIntValue(IntValue node, TraverserContext<Node> context) { return changeNode(context, node.transform(builder -> builder.value(BigInteger.ZERO))); }
@Override public Integer parseLiteral(Object input) { if (!(input instanceof IntValue)) { throw new CoercingParseLiteralException( "Expected AST type 'IntValue' but was '" + typeName(input) + "'." ); } BigInteger value = ((IntValue) input).getValue(); if (value.compareTo(INT_MIN) < 0 || value.compareTo(INT_MAX) > 0) { throw new CoercingParseLiteralException( "Expected value to be in the Integer range but it was '" + value.toString() + "'" ); } return value.intValue(); } });
@Override public IntValue deepCopy() { return new IntValue(value, getSourceLocation(), getComments(), IgnoredChars.EMPTY); }
return IntValue.newIntValue().value(new BigInteger(stringValue)).build();
@Override public String parseLiteral(Object input) { if (input instanceof StringValue) { return ((StringValue) input).getValue(); } if (input instanceof IntValue) { return ((IntValue) input).getValue().toString(); } throw new CoercingParseLiteralException( "Expected AST type 'IntValue' or 'StringValue' but was '" + typeName(input) + "'." ); } });
protected Value createValue(GraphqlParser.ValueContext ctx) { if (ctx.IntValue() != null) { IntValue.Builder intValue = IntValue.newIntValue().value(new BigInteger(ctx.IntValue().getText())); addCommonData(intValue, ctx); return intValue.build();
@Override public Short parseLiteral(Object input) { if (!(input instanceof IntValue)) { throw new CoercingParseLiteralException( "Expected AST type 'IntValue' but was '" + typeName(input) + "'." ); } BigInteger value = ((IntValue) input).getValue(); if (value.compareTo(SHORT_MIN) < 0 || value.compareTo(SHORT_MAX) > 0) { throw new CoercingParseLiteralException( "Expected value to be in the Short range but it was '" + value.toString() + "'" ); } return value.shortValue(); } });
protected Value createValue(GraphqlParser.ValueWithVariableContext ctx) { if (ctx.IntValue() != null) { IntValue.Builder intValue = IntValue.newIntValue().value(new BigInteger(ctx.IntValue().getText())); addCommonData(intValue, ctx); return intValue.build();
@Override public Byte parseLiteral(Object input) { if (!(input instanceof IntValue)) { throw new CoercingParseLiteralException( "Expected AST type 'IntValue' but was '" + typeName(input) + "'." ); } BigInteger value = ((IntValue) input).getValue(); if (value.compareTo(BYTE_MIN) < 0 || value.compareTo(BYTE_MAX) > 0) { throw new CoercingParseLiteralException( "Expected value to be in the Byte range but it was '" + value.toString() + "'" ); } return value.byteValue(); } });
private static Value handleNumber(String stringValue) { if (stringValue.matches("^[0-9]+$")) { return IntValue.newIntValue().value(new BigInteger(stringValue)).build(); } else { return FloatValue.newFloatValue().value(new BigDecimal(stringValue)).build(); } }
@Override public Long parseLiteral(Object input) { if (input instanceof StringValue) { try { return Long.parseLong(((StringValue) input).getValue()); } catch (NumberFormatException e) { throw new CoercingParseLiteralException( "Expected value to be a Long but it was '" + String.valueOf(input) + "'" ); } } else if (input instanceof IntValue) { BigInteger value = ((IntValue) input).getValue(); if (value.compareTo(LONG_MIN) < 0 || value.compareTo(LONG_MAX) > 0) { throw new CoercingParseLiteralException( "Expected value to be in the Long range but it was '" + value.toString() + "'" ); } return value.longValue(); } throw new CoercingParseLiteralException( "Expected AST type 'IntValue' or 'StringValue' but was '" + typeName(input) + "'." ); } });
return IntValue.newIntValue().value(new BigInteger(stringValue)).build();