@Override public double doubleValue() { return longValue(); }
@Override public boolean equals( long x ) { return longValue() == x; }
public static long safeCastIntegral( String name, AnyValue value, long defaultValue ) { if ( value == null || value == Values.NO_VALUE ) { return defaultValue; } if ( value instanceof IntegralValue ) { return ((IntegralValue) value).longValue(); } throw new IllegalArgumentException( name + " must be an integer value, but was a " + value.getClass().getSimpleName() ); }
@Override public LongValue minus( long b ) { return ValueMath.subtract( longValue(), b ); }
public static double coerceToDouble( Value value ) { if ( value instanceof IntegralValue ) { return ((IntegralValue) value).longValue(); } if ( value instanceof FloatingPointValue ) { return ((FloatingPointValue) value).doubleValue(); } throw new UnsupportedOperationException( format( "Cannot coerce %s to double", value ) ); }
@Override public final int computeHash() { return NumberValues.hash( longValue() ); }
@Override public LongValue dividedBy( long b ) { return Values.longValue( longValue() / b ); }
@Override public boolean equals( double x ) { return NumberValues.numbersEqual( x, longValue() ); }
@Override public long updateHash( HashFunction hashFunction, long hash ) { return hashFunction.update( hash, longValue() ); }
@Override public DoubleValue times( double b ) { return ValueMath.multiply( longValue(), b ); }
@Override public final boolean equals( Value other ) { if ( other instanceof IntegralValue ) { IntegralValue that = (IntegralValue) other; return this.longValue() == that.longValue(); } else if ( other instanceof FloatingPointValue ) { FloatingPointValue that = (FloatingPointValue) other; return NumberValues.numbersEqual( that.doubleValue(), this.longValue() ); } else { return false; } }
@Override public DoubleValue minus( double b ) { return ValueMath.subtract( longValue(), b ); }
@Override public LongValue plus( long b ) { return ValueMath.add( longValue(), b ); }
@Override public DoubleValue plus( double b ) { return ValueMath.add( longValue(), b ); }
@Override public LongValue times( long b ) { return ValueMath.multiply( longValue(), b ); }
public static DateTimeValue ofEpochMillis( IntegralValue millisUTC ) { return new DateTimeValue( assertValidArgument( () -> ofInstant( ofEpochMilli( millisUTC.longValue() ), UTC ) ) ); }
private void assignIntegral( String key, Object value, Consumer<Integer> assigner ) { if ( value instanceof String ) { assigner.accept( assertConvertible( () -> Integer.parseInt( (String) value ) ) ); } else if ( value instanceof IntegralValue ) { assigner.accept( (int) ((IntegralValue) value).longValue() ); } else { throw new InvalidValuesArgumentException( String.format( "Cannot assign %s to field %s", value, key ) ); } }
@Override public int compareTo( IntegralValue other ) { return NumberValues.compareDoubleAgainstLong( doubleValue(), other.longValue() ); }
@Override public int compareTo( FloatingPointValue other ) { return NumberValues.compareLongAgainstDouble( longValue(), other.doubleValue() ); }