@Override public JoinRow map(ResultSet r, StatementContext ctx) throws SQLException { return specialize(r, ctx).map(r, ctx); }
/** * Register a column mapper for a given explicit {@link Type} * Column mappers may be reused by {@link RowMapper} to map individual columns. * * @param type the type to match with equals. * @param mapper the column mapper * @return this */ public ColumnMappers register(Type type, ColumnMapper<?> mapper) { return this.register(ColumnMapperFactory.of(type, mapper)); }
private static RowMapper<?> getKeyMapper(Type keyType, ConfigRegistry config) { String column = config.get(MapEntryMappers.class).getKeyColumn(); if (column == null) { return config.get(RowMappers.class) .findFor(keyType) .orElseThrow(() -> new NoSuchMapperException("No row mapper registered for map key " + keyType)); } else { return config.get(ColumnMappers.class) .findFor(keyType) .map(mapper -> new SingleColumnMapper<>(mapper, column)) .orElseThrow(() -> new NoSuchMapperException("No column mapper registered for map key " + keyType + " in column " + column)); } }
private static RowMapper<?> getValueMapper(Type valueType, ConfigRegistry config) { String column = config.get(MapEntryMappers.class).getValueColumn(); if (column == null) { return config.get(RowMappers.class) .findFor(valueType) .orElseThrow(() -> new NoSuchMapperException("No row mapper registered for map value " + valueType)); } else { return config.get(ColumnMappers.class) .findFor(valueType) .map(mapper -> new SingleColumnMapper<>(mapper, column)) .orElseThrow(() -> new NoSuchMapperException("No column mapper registered for map value " + valueType + " in column " + column)); } }
public ColumnMappers() { // TODO move to BuiltInSupportPlugin register(new SqlArrayMapperFactory()); register(new JavaTimeMapperFactory()); register(new SqlTimeMapperFactory()); register(new InternetMapperFactory()); register(new EssentialsMapperFactory()); register(new BoxedMapperFactory()); register(new PrimitiveMapperFactory()); register(new OptionalMapperFactory()); register(new EnumMapperFactory()); register(new NVarcharMapper()); }
@Override public Map<String, Object> map(ResultSet rs, StatementContext ctx) throws SQLException { return specialize(rs, ctx).map(rs, ctx); }
@Override public Map<String, T> map(ResultSet rs, StatementContext ctx) throws SQLException { return specialize(rs, ctx).map(rs, ctx); }
/** * Register a column mapper which will have its parameterized type inspected to determine what it maps to. * Column mappers may be reused by {@link RowMapper} to map individual columns. * <p> * The parameter must be concretely parameterized, we use the type argument T to * determine if it applies to a given type. * * @param mapper the column mapper * @return this * @throws UnsupportedOperationException if the ColumnMapper is not a concretely parameterized type */ public ColumnMappers register(ColumnMapper<?> mapper) { return this.register(new InferredColumnMapperFactory(mapper)); }
/** * Constructs a row mapper which maps the column with the given label. * @param mapper the column mapper to delegate to for mapping * @param columnLabel the label of the column to map */ public SingleColumnMapper(ColumnMapper<T> mapper, String columnLabel) { this.delegate = (r, ctx) -> mapper.map(r, columnLabel, ctx); }
/** * Register a column mapper factory. * <p> * Column mappers may be reused by {@link RowMapper} to map individual columns. * * @param factory the column mapper factory * @return this */ public ColumnMappers register(ColumnMapperFactory factory) { return register(QualifiedColumnMapperFactory.adapt(factory)); }
/** * Register a row mapper which will have its parameterized type inspected to determine what it maps to. * Will be used with {@link Query#mapTo(Class)} for registered mappings. * <p> * The parameter must be concretely parameterized, we use the type argument T to * determine if it applies to a given type. * * @param mapper the row mapper * @return this * @throws UnsupportedOperationException if the RowMapper is not a concretely parameterized type */ public RowMappers register(RowMapper<?> mapper) { return this.register(new InferredRowMapperFactory(mapper)); }
@Override public RowMapper<Map.Entry<K, V>> specialize(ResultSet rs, StatementContext ctx) throws SQLException { return new MapEntryMapper<>(keyMapper.specialize(rs, ctx), valueMapper.specialize(rs, ctx)); }
@Override public ColumnMappers createCopy() { return new ColumnMappers(this); } }
/** * Converts to {@link ImmutableFooBarBaz ImmutableFooBarBaz}. * @return An immutable instance of FooBarBaz */ public final ImmutableFooBarBaz toImmutable() { checkRequiredAttributes(); return ImmutableFooBarBaz.copyOf(this); }
@Override public Mappers createCopy() { return new Mappers(); } }
/** * @param <E> the enum type to map * @param type the enum type to map * @return an enum mapper that matches on {@link Enum#ordinal()} */ public static <E extends Enum<E>> ColumnMapper<E> byOrdinal(Class<E> type) { return new EnumByOrdinalColumnMapper<>(type); }
@Override public MapMappers createCopy() { return new MapMappers(this); } }
/** * Copy the current immutable object by setting a value for the {@link ImmutablesTest.Train#carriages() carriages} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for carriages * @return A modified copy of the {@code this} object */ public final ImmutableTrain withCarriages(int value) { if (this.carriages == value) return this; return new ImmutableTrain(this.name, value, this.observationCar); }
/** * Creates a builder for {@link ImmutableTrain ImmutableTrain}. * @return A new ImmutableTrain builder */ public static ImmutableTrain.Builder builder() { return new ImmutableTrain.Builder(); }