Package com.d3x.core.db
Class DatabaseRecord
- java.lang.Object
-
- com.d3x.core.db.DatabaseRecord
-
public class DatabaseRecord extends java.lang.ObjectA convenience container that provides a generic mapping class to a row in a database table. It is not advisable to use this generic container for large volume I/O against a database.- Author:
- Xavier Witdouck
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classDatabaseRecord.MappingA DatabaseMapping for the DatabaseRecord class
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.Object>values
-
Constructor Summary
Constructors Modifier Constructor Description privateDatabaseRecord(java.util.Map<java.lang.String,java.lang.Object> values)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> com.d3x.core.util.Option<T>getValue(java.lang.String name)Returns an option on the value with the name<T> TgetValueOrFail(java.lang.String name)Returns an option on the value with the namejava.util.Map<java.lang.String,java.lang.Object>getValues()java.util.Set<java.lang.String>names()Returns the set of field names for recordstatic DatabaseRecordof(java.util.function.Consumer<java.util.Map<java.lang.String,java.lang.Object>> consumer)Returns a newly created record based on what the consumer puts in mapintsize()Returns the number of entries for this recordjava.util.Collection<java.lang.Object>values()Returns the field values for this record
-
-
-
Method Detail
-
of
public static DatabaseRecord of(java.util.function.Consumer<java.util.Map<java.lang.String,java.lang.Object>> consumer)
Returns a newly created record based on what the consumer puts in map- Parameters:
consumer- the consumer to populate the field key-value pairs- Returns:
- the newly created record
-
size
public int size()
Returns the number of entries for this record- Returns:
- the number of entries
-
names
public java.util.Set<java.lang.String> names()
Returns the set of field names for record- Returns:
- the field names
-
values
public java.util.Collection<java.lang.Object> values()
Returns the field values for this record- Returns:
- the field values for record
-
getValue
public <T> com.d3x.core.util.Option<T> getValue(java.lang.String name)
Returns an option on the value with the name- Type Parameters:
T- the value type- Parameters:
name- the field name- Returns:
- the option on value
-
getValueOrFail
public <T> T getValueOrFail(java.lang.String name)
Returns an option on the value with the name- Type Parameters:
T- the value type- Parameters:
name- the field name- Returns:
- the option on value
-
getValues
public java.util.Map<java.lang.String,java.lang.Object> getValues()
-
-