Java 8 OptionalDouble - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 OptionalDouble class.

This code example shows how to use the following methods:getAsDouble, isPresent
 * Extracts the value contained by the {@link OptionalDouble} for validation, or produces {@code null}. 
 */ 
public class OptionalDoubleValidatedValueUnwrapper extends ValidatedValueUnwrapper<OptionalDouble> {
    @Override 
    public Object handleValidatedValue(final OptionalDouble optional) {
        return optional.isPresent() ? optional.getAsDouble() : null;
    } 
 
    @Override 
    public Type getValidatedValueType(final Type type) {
        return Double.class;
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAsDouble, isPresent
 
        @Override 
        public void apply(int position,
                          PreparedStatement statement,
                          StatementContext ctx) throws SQLException {
            if (value.isPresent()) {
                statement.setDouble(position, value.getAsDouble());
            } else { 
                statement.setNull(position, Types.DOUBLE);
            } 
        } 
    } 
 
    @Override 
    public boolean accepts(Class<?> expectedType, Object value, StatementContext ctx) {
        return value instanceof OptionalDouble;
    } 
 
    @Override 
    public Argument build(Class<?> expectedType, OptionalDouble value, StatementContext ctx) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAsDouble, isPresent
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAsDouble, isPresent
        } 
 
        @Override 
        public String toString(final OptionalDouble value) {
            checkArgument(value != null);
            return value.isPresent() ? Double.toString(value.getAsDouble()) : "";
        } 
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAsDouble, isPresent
 
    @Override 
    public void serialize(OptionalDouble value, JsonGenerator gen, SerializerProvider provider)
        throws IOException
    { 
        if (value.isPresent()) {
            gen.writeNumber(value.getAsDouble());
        } else { 
            gen.writeNull();
        } 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAsDouble, isPresent
        return OptionalDouble.empty();
    } 
 
    @Override 
    public void set(OptionalDouble optional) {
        if (optional != null && optional.isPresent()) {
            wrapper.set(optional.getAsDouble());
        } else { 
            wrapper.set(null); 
        } 
    } 
 
    @Override 
    public Wrapper<Double> getWrapper() {
        return wrapper; 
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 OptionalDouble Methods: