public class EnumMapping extends SingleFieldMapping
| Modifier and Type | Field and Description |
|---|---|
protected String |
datastoreJavaType |
protected static String |
ENUM_GETTER_BY_VALUE |
protected static String |
ENUM_VALUE_GETTER |
absFieldNumber, datastoreMappings, mmd, referenceMapping, roleForMember, storeMgr, table, type| Constructor and Description |
|---|
EnumMapping() |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
getEnumValueForMethod(Class enumType,
long val,
String methodName)
Convenience method to return the value of an Enum using a static getter method, passing in a value.
|
String |
getGetValueMethodName()
Accessor for the "getValue" getter name if that extension is enabled for this mapping.
|
Class |
getJavaType()
Accessor for the java type being mapped.
|
String |
getJavaTypeForDatastoreMapping(int index)
Accessor for the name of the java-type actually used when mapping the particular datastore
field.
|
Object |
getObject(org.datanucleus.ExecutionContext ec,
ResultSet resultSet,
int[] exprIndex)
Method to extract the Enum object from the passed result set.
|
Object[] |
getValidValues(int index)
Accessor for the valid values for this mapping (if any restriction is imposed).
|
protected Long |
getValueForEnumUsingMethod(Enum value,
String methodName)
Convenience method to get the value to be persisted for an Enum via a method call.
|
int |
getValueForEnumUsingMethod(Enum value,
String methodName,
int defaultVal) |
void |
initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd,
Table table,
org.datanucleus.ClassLoaderResolver clr)
Initialize this JavaTypeMapping with the given DatastoreAdapter for the given member MetaData.
|
void |
setObject(org.datanucleus.ExecutionContext ec,
PreparedStatement ps,
int[] exprIndex,
Object value)
Method to set the Enum in the datastore statement.
|
getBoolean, getByte, getChar, getDefaultLength, getDouble, getFloat, getInt, getLong, getShort, getString, prepareDatastoreMapping, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setStringaddDatastoreMapping, equals, failureMessage, getAbsoluteFieldNumber, getColumnMetaDataForMember, getDatastoreMapping, getDatastoreMappings, getMemberMetaData, getNumberOfDatastoreMappings, getObject, getReferenceMapping, getRoleForMember, getStoreManager, getTable, getType, getValueForDatastoreMapping, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, initialize, isNullable, isSerialised, representableAsStringLiteralInStatement, setAbsFieldNumber, setMemberMetaData, setObject, setReferenceMapping, setRoleForMember, setTableprotected static final String ENUM_VALUE_GETTER
protected static final String ENUM_GETTER_BY_VALUE
protected String datastoreJavaType
public void initialize(org.datanucleus.metadata.AbstractMemberMetaData mmd,
Table table,
org.datanucleus.ClassLoaderResolver clr)
initialize in class SingleFieldMappingmmd - MetaData for the member to be mapped (if any)table - The table storing this mapping (if any)clr - the ClassLoaderResolverpublic Object[] getValidValues(int index)
getValidValues in class SingleFieldMappingindex - The index of the datastore columnpublic String getJavaTypeForDatastoreMapping(int index)
getJavaTypeForDatastoreMapping in class SingleFieldMappingindex - requested datastore field index.public Class getJavaType()
JavaTypeMappinggetJavaType in class JavaTypeMappingpublic void setObject(org.datanucleus.ExecutionContext ec,
PreparedStatement ps,
int[] exprIndex,
Object value)
setObject in class SingleFieldMappingec - ExecutionContextps - Statement for the datastoreexprIndex - Index position(s) to set the Enum at in the statementvalue - The Enum value to setprotected Long getValueForEnumUsingMethod(Enum value, String methodName)
value - The Enum valuemethodName - The name of the methodpublic int getValueForEnumUsingMethod(Enum value, String methodName, int defaultVal)
public Object getObject(org.datanucleus.ExecutionContext ec, ResultSet resultSet, int[] exprIndex)
getObject in class SingleFieldMappingec - ExecutionContextresultSet - The result setexprIndex - The index position(s) in the result set to use.protected Object getEnumValueForMethod(Class enumType, long val, String methodName)
enumType - The type of the enumval - The value to pass inmethodName - Name of the static methodpublic String getGetValueMethodName()
Copyright © 2015. All rights reserved.