Package io.ebeaninternal.server.type
Class EnumToDbValueMap<T>
- java.lang.Object
-
- io.ebeaninternal.server.type.EnumToDbValueMap<T>
-
- Direct Known Subclasses:
EnumToDbIntegerMap
,EnumToDbStringMap
public abstract class EnumToDbValueMap<T> extends Object
Used to map Bean values to DB values.Useful for building Enum converters where you want to map the DB values an Enum gets converter to.
-
-
Constructor Summary
Constructors Constructor Description EnumToDbValueMap()
Construct with allowNulls defaulting to false.EnumToDbValueMap(boolean allowNulls, boolean isIntegerType)
Construct with allowNulls setting.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract EnumToDbValueMap<T>
add(Object beanValue, String dbValue, String name)
Add name value pair where the dbValue is the raw string and may need to be converted (to an Integer for example).abstract void
bind(DataBind b, Object value)
Bind using the correct database type.static EnumToDbValueMap<?>
create(boolean integerType)
Iterator<T>
dbValues()
Return the DB values.Object
getBeanValue(T dbValue)
Return the Bean value given the DB value.abstract int
getDbType()
Return the database type.T
getDbValue(Object beanValue)
Return the DB value given the bean value.boolean
isIntegerType()
Return true if this is mapping to integers, false if mapping to Strings.abstract Object
read(DataReader dataReader)
Read using the correct database type.
-
-
-
Constructor Detail
-
EnumToDbValueMap
public EnumToDbValueMap()
Construct with allowNulls defaulting to false.
-
EnumToDbValueMap
public EnumToDbValueMap(boolean allowNulls, boolean isIntegerType)
Construct with allowNulls setting.If allowNulls is false then an IllegalArgumentException is thrown by either the getDBValue or getBeanValue methods if not matching Bean or DB value is found.
-
-
Method Detail
-
create
public static EnumToDbValueMap<?> create(boolean integerType)
-
isIntegerType
public boolean isIntegerType()
Return true if this is mapping to integers, false if mapping to Strings.
-
bind
public abstract void bind(DataBind b, Object value) throws SQLException
Bind using the correct database type.- Throws:
SQLException
-
read
public abstract Object read(DataReader dataReader) throws SQLException
Read using the correct database type.- Throws:
SQLException
-
getDbType
public abstract int getDbType()
Return the database type.
-
add
public abstract EnumToDbValueMap<T> add(Object beanValue, String dbValue, String name)
Add name value pair where the dbValue is the raw string and may need to be converted (to an Integer for example).
-
getDbValue
public T getDbValue(Object beanValue)
Return the DB value given the bean value.
-
getBeanValue
public Object getBeanValue(T dbValue)
Return the Bean value given the DB value.
-
-