@Override public double doubleValue() { return longValue(); }
@Override public DoubleValue dividedBy( double b ) { return Values.doubleValue( doubleValue() / b ); } }
@Override public boolean eq( Object other ) { return other instanceof Value && equals( (Value) other ); }
.ofInstant( Instant.ofEpochMilli( epochSeconds.longValue() * 1000 ), timezone() ) ); .ofInstant( Instant.ofEpochMilli( epochMillis.longValue() ), timezone() ) ); safeCastIntegral( TemporalFields.year.name(), fields.get( TemporalFields.year ), TemporalFields.year.defaultValue ) ) .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 )
safeCastIntegral( f.name(), entry.getValue(), f.defaultValue ) ); .with( temporalField, safeCastIntegral( f.name(), entry.getValue(), f.defaultValue ) );
.ofInstant( Instant.ofEpochMilli( epochSeconds.longValue() * 1000 ), timezone() ) ); .ofInstant( Instant.ofEpochMilli( epochMillis.longValue() ), timezone() ) ); safeCastIntegral( TemporalFields.year.name(), fields.get( TemporalFields.year ), TemporalFields.year.defaultValue ) ) .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 )
@Override public DateValue buildInternal() { LocalDate result; if ( fields.containsKey( TemporalFields.date ) ) { result = getDateOf( fields.get( TemporalFields.date ) ); } else if ( fields.containsKey( TemporalFields.week ) ) { // Be sure to be in the start of the week based year (which can be later than 1st Jan) result = DEFAULT_CALENDER_DATE .with( IsoFields.WEEK_BASED_YEAR, safeCastIntegral( TemporalFields.year.name(), fields.get( TemporalFields.year ), TemporalFields.year.defaultValue ) ) .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 ) .with( ChronoField.DAY_OF_WEEK, 1 ); } else { result = DEFAULT_CALENDER_DATE; } result = assignAllFields( result ); return date( result ); }
@Override public boolean equals( long x ) { return longValue() == x; }
public static double safeCastFloatingPoint( String name, AnyValue value, double defaultValue ) { if ( value == null ) { return defaultValue; } if ( value instanceof IntegralValue ) { return ((IntegralValue) value).doubleValue(); } if ( value instanceof FloatingPointValue ) { return ((FloatingPointValue) value).doubleValue(); } throw new IllegalArgumentException( name + " must be a number value, but was a " + value.getClass().getSimpleName() ); }
safeCastIntegral( f.name(), entry.getValue(), f.defaultValue ) ); .with( temporalField, safeCastIntegral( f.name(), entry.getValue(), f.defaultValue ) );
@Override public boolean eq( Object other ) { return other instanceof Value && equals( (Value) other ); }
private void assignFloatingPoint( String key, Object value, Consumer<Double> assigner ) { if ( value instanceof String ) { assigner.accept( assertConvertible( () -> Double.parseDouble( (String) value ) ) ); } else if ( value instanceof IntegralValue ) { assigner.accept( ((IntegralValue) value).doubleValue() ); } else if ( value instanceof FloatingPointValue ) { assigner.accept( ((FloatingPointValue) value).doubleValue() ); } else { throw new InvalidValuesArgumentException( String.format( "Cannot assign %s to field %s", value, key ) ); } }
@Override public DateValue buildInternal() { LocalDate result; if ( fields.containsKey( TemporalFields.date ) ) { result = getDateOf( fields.get( TemporalFields.date ) ); } else if ( fields.containsKey( TemporalFields.week ) ) { // Be sure to be in the start of the week based year (which can be later than 1st Jan) result = DEFAULT_CALENDER_DATE .with( IsoFields.WEEK_BASED_YEAR, safeCastIntegral( TemporalFields.year.name(), fields.get( TemporalFields.year ), TemporalFields.year.defaultValue ) ) .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 ) .with( ChronoField.DAY_OF_WEEK, 1 ); } else { result = DEFAULT_CALENDER_DATE; } result = assignAllFields( result ); return date( result ); }
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 DoubleValue dividedBy( double b ) { return Values.doubleValue( doubleValue() / b ); } }
@Override public boolean equals( double x ) { return NumberValues.numbersEqual( x, longValue() ); }
public static double safeCastFloatingPoint( String name, AnyValue value, double defaultValue ) { if ( value == null ) { return defaultValue; } if ( value instanceof IntegralValue ) { return ((IntegralValue) value).doubleValue(); } if ( value instanceof FloatingPointValue ) { return ((FloatingPointValue) value).doubleValue(); } throw new IllegalArgumentException( name + " must be a number value, but was a " + value.getClass().getSimpleName() ); }
@Override public long updateHash( HashFunction hashFunction, long hash ) { return hashFunction.update( hash, longValue() ); }
private void assignFloatingPoint( String key, Object value, Consumer<Double> assigner ) { if ( value instanceof String ) { assigner.accept( assertConvertible( () -> Double.parseDouble( (String) value ) ) ); } else if ( value instanceof IntegralValue ) { assigner.accept( ((IntegralValue) value).doubleValue() ); } else if ( value instanceof FloatingPointValue ) { assigner.accept( ((FloatingPointValue) value).doubleValue() ); } else { throw new InvalidValuesArgumentException( String.format( "Cannot assign %s to field %s", value, key ) ); } }