@Test void rowMapper() throws SQLException { when(resultSet.getInt("bob")).thenReturn(44); when(resultSet.wasNull()).thenReturn(false); when(scope.database()).thenReturn(database); when(database.dialect()).thenReturn(dialect); when(dialect.type(DbTypeId.INTEGER)).thenReturn(new DefaultInteger()); CastBuilder<String> builder = new CastBuilder<>(expression); TypedExpression<Integer> sut = builder.asInteger(); RowMapper<Integer> result = sut.rowMapper(scope, Optional.of("bob")); assertThat(result.mapRow(resultSet), is(44)); verifyNoMoreInteractions(expression, scope, dialect, database, resultSet); }
@Override public RowMapper<T> rowMapper(Scope scope, Optional<String> label) { return rs -> to.get(rs, label.orElseGet(() -> label(scope)), scope.database()).orElse(null); }
CastExpression implements TypedExpression<T> { @Override public RowMapper<T> rowMapper(Scope scope, Optional<String> label) { return rs -> to.get(rs, label.orElseGet(() -> label(scope)), scope.database()).orElse(null); } }
CastExpression implements TypedExpression<T> { @Override public RowMapper<T> rowMapper(Scope scope, Optional<String> label) { return rs -> to.get(rs, label.orElseGet(() -> label(scope)), scope.database()).orElse(null); } CastExpression(TypedExpression<F> from, DataType<T> to, DbTypeId<T> toType, BiFunction<DbType<T>,Database,String> toSql); }
CastExpression implements TypedExpression<T> { @Override public RowMapper<T> rowMapper(Scope scope, Optional<String> label) { return rs -> to.get(rs, label.orElseGet(() -> label(scope)), scope.database()).orElse(null); } CastExpression(TypedExpression<F> from, DataType<T> to, DbTypeId<T> toType, BiFunction<DbType<T>,Database,String> toSql); @Override String label(Scope scope); @Override RowMapper<T> rowMapper(Scope scope, Optional<String> label); @Override TypeToken<T> type(); @Override String sql(Scope scope); @Override Stream<Object> args(Scope scope); @Override Precedence precedence(); @Override String toString(); }
CastExpression implements TypedExpression<T> { @Override public RowMapper<T> rowMapper(Scope scope, Optional<String> label) { return rs -> to.get(rs, label.orElseGet(() -> label(scope)), scope.database()).orElse(null); } CastExpression(TypedExpression<F> from, DataType<T> to, DbTypeId<T> toType, BiFunction<DbType<T>,Database,String> toSql); @Override String label(Scope scope); @Override RowMapper<T> rowMapper(Scope scope, Optional<String> label); @Override TypeToken<T> type(); @Override String sql(Scope scope); @Override Stream<Object> args(Scope scope); @Override Precedence precedence(); @Override String toString();  }