Interface Mappable<T extends BaseEntity>
-
- All Known Implementing Classes:
BaseMapper
public interface Mappable<T extends BaseEntity>- Author:
- Collin Alpert
-
-
Method Summary
Modifier and Type Method Description java.util.Optional<T>map(java.sql.ResultSet set, java.util.Map<java.lang.String,java.lang.String> aliases)Maps aResultSetto anOptional.T[]mapToArray(java.sql.ResultSet set, java.util.Map<java.lang.String,java.lang.String> aliases)Maps aResultSetto an array.java.util.List<T>mapToList(java.sql.ResultSet set, java.util.Map<java.lang.String,java.lang.String> aliases)Maps aResultSetto aList.<K,V>
java.util.Map<K,V>mapToMap(java.sql.ResultSet set, java.util.function.Function<T,K> keyMapping, java.util.function.Function<T,V> valueMapping, java.util.Map<java.lang.String,java.lang.String> aliases)Maps aResultSetto aMap.java.util.stream.Stream<T>mapToStream(java.sql.ResultSet set, java.util.Map<java.lang.String,java.lang.String> aliases)Maps aResultSetto aStream.
-
-
-
Method Detail
-
map
java.util.Optional<T> map(java.sql.ResultSet set, java.util.Map<java.lang.String,java.lang.String> aliases) throws java.sql.SQLException
Maps aResultSetto anOptional. Should be used when only one result is expected from the database.- Parameters:
set- TheResultSetto get the data from.aliases- A map of column aliases needed to retrieve column data from theResultSet.- Returns:
- An
Optionalcontaining theResultSets data. - Throws:
java.sql.SQLException- In case theResultSetcan't be read.
-
mapToList
java.util.List<T> mapToList(java.sql.ResultSet set, java.util.Map<java.lang.String,java.lang.String> aliases) throws java.sql.SQLException
Maps aResultSetto aList.- Parameters:
set- TheResultSetto get the data from.aliases- A map of column aliases needed to retrieve column data from theResultSet.- Returns:
- A
Listcontaining theResultSets data. - Throws:
java.sql.SQLException- In case theResultSetcan't be read.
-
mapToStream
java.util.stream.Stream<T> mapToStream(java.sql.ResultSet set, java.util.Map<java.lang.String,java.lang.String> aliases) throws java.sql.SQLException
Maps aResultSetto aStream.- Parameters:
set- TheResultSetto get the data from.aliases- A map of column aliases needed to retrieve column data from theResultSet.- Returns:
- A
Streamcontaining theResultSets data. - Throws:
java.sql.SQLException- In case theResultSetcan't be read.
-
mapToArray
T[] mapToArray(java.sql.ResultSet set, java.util.Map<java.lang.String,java.lang.String> aliases) throws java.sql.SQLException
Maps aResultSetto an array.- Parameters:
set- TheResultSetto get the data from.aliases- A map of column aliases needed to retrieve column data from theResultSet.- Returns:
- An array containing the
ResultSets data. - Throws:
java.sql.SQLException- In case theResultSetcan't be read.
-
mapToMap
<K,V> java.util.Map<K,V> mapToMap(java.sql.ResultSet set, java.util.function.Function<T,K> keyMapping, java.util.function.Function<T,V> valueMapping, java.util.Map<java.lang.String,java.lang.String> aliases) throws java.sql.SQLExceptionMaps aResultSetto aMap.- Type Parameters:
K- The type of the keys in the map.V- The type of the values in the map.- Parameters:
set- TheResultSetto get the data from.keyMapping- The key function of the map.valueMapping- The value function of the map.aliases- A map of column aliases needed to retrieve column data from theResultSet.- Returns:
- A
Mapcontaining theResultSets data. - Throws:
java.sql.SQLException- In case theResultSetcan't be read.
-
-