Java 8 OptionalInt - 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 OptionalInt class.

This code example shows how to use the following methods:getAsInt, isPresent
 * Extracts the value contained by the {@link OptionalInt} for validation, or produces {@code null}. 
 */ 
public class OptionalIntValidatedValueUnwrapper extends ValidatedValueUnwrapper<OptionalInt> {
    @Override 
    public Object handleValidatedValue(final OptionalInt optional) {
        return optional.isPresent() ? optional.getAsInt() : null;
    } 
 
    @Override 
    public Type getValidatedValueType(final Type type) {
        return Integer.class;
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsInt, isPresent
 
        @Override 
        public void apply(int position,
                          PreparedStatement statement,
                          StatementContext ctx) throws SQLException {
            if (value.isPresent()) {
                statement.setInt(position, value.getAsInt());
            } else { 
                statement.setNull(position, Types.INTEGER);
            } 
        } 
    } 
 
    @Override 
    public boolean accepts(Class<?> expectedType, Object value, StatementContext ctx) {
        return value instanceof OptionalInt;
    } 
 
    @Override 
    public Argument build(Class<?> expectedType, OptionalInt value, StatementContext ctx) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsInt, isPresent
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsInt, isPresent
        } 
 
        @Override 
        public String toString(final OptionalInt value) {
            checkArgument(value != null);
            return value.isPresent() ? Integer.toString(value.getAsInt()) : "";
        } 
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsInt, isPresent
     
    @Override 
    public void serialize(OptionalInt value, JsonGenerator gen, SerializerProvider provider)
        throws IOException
    { 
        if (value.isPresent()) {
            gen.writeNumber(value.getAsInt());
        } else { 
            gen.writeNull();
        } 
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsInt, isPresent
 
    @Override 
    public String toString()
    { 
        return toStringHelper(this)
                .add("bucketNumber", bucketNumber.isPresent() ? bucketNumber.getAsInt() : null)
                .add("shards", shards)
                .omitNullValues()
                .toString();
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsInt, isPresent
    public String toString()
    { 
        return toStringHelper(this)
                .add("tableId", tableId)
                .add("shards", shards)
                .add("bucketNumber", bucketNumber.isPresent() ? bucketNumber.getAsInt() : null)
                .omitNullValues()
                .toString();
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsInt, isPresent
    public String toString()
    { 
        return toStringHelper(this)
                .add("tableId", tableId)
                .add("distributionId", distributionId.isPresent() ? distributionId.getAsLong() : null)
                .add("bucketCount", bucketCount.isPresent() ? bucketCount.getAsInt() : null)
                .add("temporalColumnId", temporalColumnId.isPresent() ? temporalColumnId.getAsLong() : null)
                .omitNullValues()
                .toString();
    } 
 
    public static class TableMapper
            implements ResultSetMapper<Table>
    { 
        @Override 
        public Table map(int index, ResultSet r, StatementContext ctx)
                throws SQLException
        { 
            return new Table(
                    r.getLong("table_id"),
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsInt, isPresent
    @Override 
    public String toString()
    { 
        return toStringHelper(this)
                .add("shardUuid", shardUuid)
                .add("bucketNumber", bucketNumber.isPresent() ? bucketNumber.getAsInt() : null)
                .add("nodeIdentifiers", nodeIdentifiers)
                .add("columnStats", columnStats)
                .add("rowCount", rowCount)
                .add("compressedSize", compressedSize)
                .add("uncompressedSize", uncompressedSize)
                .omitNullValues()
                .toString();
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsInt, isPresent
    @Override 
    public String toString()
    { 
        return toStringHelper(this)
                .add("tableId", tableId)
                .add("bucketNumber", bucketNumber.isPresent() ? bucketNumber.getAsInt() : null)
                .add("shardUuid", shardUuid)
                .add("rowCount", rowCount)
                .add("uncompressedSize", uncompressedSize)
                .add("sortRange", sortRange.orElse(null))
                .add("temporalRange", temporalRange.orElse(null))
                .omitNullValues()
                .toString();
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 OptionalInt Methods: