Interface CustomColumnMapper
public interface CustomColumnMapper
Enables per-column
ResultSet mapping customization via ResultSetMapper.- Since:
- 3.0.0
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classResult of a custom column mapping attempt. -
Method Summary
Modifier and TypeMethodDescriptionappliesTo(TargetType targetType) Specifies which types this mapper should handle.map(StatementContext<?> statementContext, ResultSet resultSet, Object resultSetValue, TargetType targetType, Integer columnIndex, String columnLabel, InstanceProvider instanceProvider) Perform custom mapping of aResultSetcolumn: given aresultSetValue, optionally return an instance oftargetTypeinstead.
-
Method Details
-
map
@Nonnull CustomColumnMapper.MappingResult map(@Nonnull StatementContext<?> statementContext, @Nonnull ResultSet resultSet, @Nonnull Object resultSetValue, @Nonnull TargetType targetType, @Nonnull Integer columnIndex, @Nullable String columnLabel, @Nonnull InstanceProvider instanceProvider) throws SQLException Perform custom mapping of aResultSetcolumn: given aresultSetValue, optionally return an instance oftargetTypeinstead.This method is only invoked when
resultSetValueis non-null.- Parameters:
statementContext- current SQL contextresultSet- theResultSetfrom which data was readresultSetValue- the already-read value from theResultSet, to be optionally converted to an instance oftargetTypetargetType- the type to which theresultSetValueshould be convertedcolumnIndex- 1-based column indexcolumnLabel- normalized column label, if availableinstanceProvider- instance-creation factory, may be used to instantiate values- Returns:
- the result of the custom column mapping operation - either
CustomColumnMapper.MappingResult.of(Object)to indicate a successfully-mapped value orCustomColumnMapper.MappingResult.fallback()if Pyranid should fall back to the registeredResultSetMappermapping behavior. - Throws:
SQLException- if an error occurs during mapping
-
appliesTo
Specifies which types this mapper should handle.For example, if this mapper should apply when marshaling to
MyCustomType, this method could returntargetType.matchesClass(MyCustomType.class).For parameterized types like
List<UUID>, this method could returntargetType.matchesParameterizedType(List.class, UUID.class).- Parameters:
targetType- the target type to evaluate - should this mapper handle it or not?- Returns:
trueif this mapper should handle the type,falseotherwise.
-