- 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 a ResultSet to an Optional.
|
T[] |
mapToArray(java.sql.ResultSet set,
java.util.Map<java.lang.String,java.lang.String> aliases) |
Maps a ResultSet to an array.
|
java.util.List<T> |
mapToList(java.sql.ResultSet set,
java.util.Map<java.lang.String,java.lang.String> aliases) |
Maps a ResultSet to a List.
|
<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 a ResultSet to a Map.
|
java.util.stream.Stream<T> |
mapToStream(java.sql.ResultSet set,
java.util.Map<java.lang.String,java.lang.String> aliases) |
Maps a ResultSet to a Stream.
|
-
Method Details
-
java.util.Optional<T> map(
java.sql.ResultSet set,
java.util.Map<java.lang.String,java.lang.String> aliases)
throws
java.sql.SQLException
Maps a ResultSet to an Optional. Should be used when only one result is expected from the database.
- Parameters:
set - The ResultSet to get the data from.
aliases - A map of column aliases needed to retrieve column data from the ResultSet.
- Returns:
- An
Optional containing the ResultSets data.
- Throws:
java.sql.SQLException - In case the ResultSet can't be read.
-
java.util.List<T> mapToList(
java.sql.ResultSet set,
java.util.Map<java.lang.String,java.lang.String> aliases)
throws
java.sql.SQLException
Maps a ResultSet to a List.
- Parameters:
set - The ResultSet to get the data from.
aliases - A map of column aliases needed to retrieve column data from the ResultSet.
- Returns:
- A
List containing the ResultSets data.
- Throws:
java.sql.SQLException - In case the ResultSet can't be read.
-
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 a ResultSet to a Stream.
- Parameters:
set - The ResultSet to get the data from.
aliases - A map of column aliases needed to retrieve column data from the ResultSet.
- Returns:
- A
Stream containing the ResultSets data.
- Throws:
java.sql.SQLException - In case the ResultSet can't be read.
-
T[] mapToArray(
java.sql.ResultSet set,
java.util.Map<java.lang.String,java.lang.String> aliases)
throws
java.sql.SQLException
Maps a ResultSet to an array.
- Parameters:
set - The ResultSet to get the data from.
aliases - A map of column aliases needed to retrieve column data from the ResultSet.
- Returns:
- An array containing the
ResultSets data.
- Throws:
java.sql.SQLException - In case the ResultSet can't be read.
-
<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.SQLException
Maps a ResultSet to a Map.
- Type Parameters:
K - The type of the keys in the map.
V - The type of the values in the map.
- Parameters:
set - The ResultSet to 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 the ResultSet.
- Returns:
- A
Map containing the ResultSets data.
- Throws:
java.sql.SQLException - In case the ResultSet can't be read.