T - the type of argument supported by this factory.public abstract class AbstractArgumentFactory<T> extends Object implements ArgumentFactory
ArgumentFactory base class for arguments of type T. For values of type T, factories
produces arguments from the build(Object, ConfigRegistry) method. For null values with a known expected type
of T, produces null arguments for the sqlType passed to the constructor.
class ValueType {
String value;
}
class ValueTypeArgumentFactory extends AbstractArgumentFactory<ValueType> {
ValueTypeArgumentFactory() {
super(Types.VARCHAR);
}
@Override
protected Argument build(ValueType valueType, ConfigRegistry config) {
return (pos, stmt, ctx) -> stmt.setString(pos, valueType.value);
}
}
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractArgumentFactory(int sqlType)
Constructs an
ArgumentFactory for type T. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract Argument |
build(T value,
ConfigRegistry config)
Produce an argument object for the given value.
|
Optional<Argument> |
build(Type type,
Object value,
ConfigRegistry config)
Returns an
Argument for the given value if the factory supports it; empty otherwise. |
protected AbstractArgumentFactory(int sqlType)
ArgumentFactory for type T.sqlType - the Types constant to use when the argument value is null.protected abstract Argument build(T value, ConfigRegistry config)
value - the value to convert to an argumentconfig - the config registryArgument for the given value.public final Optional<Argument> build(Type type, Object value, ConfigRegistry config)
ArgumentFactoryArgument for the given value if the factory supports it; empty otherwise.build in interface ArgumentFactorytype - the known type of value. Depending on the situation this may be a full generic signature e.g.
ParameterizedType, a Class, or Object.class if no type information
is known.value - the value to convert into an Argumentconfig - the config registry, for compositionOptional.empty() otherwise.StatementContext.findArgumentFor(Type, Object),
Arguments.findFor(Type, Object)Copyright © 2017. All rights reserved.