Class AbstractMetaDataDefaults
- All Implemented Interfaces:
CallbackModes, MetaDataDefaults
- Direct Known Subclasses:
PersistenceMetaDataDefaults
- Author:
- Abe White, Pinaki Poddar
-
Field Summary
Fields inherited from interface CallbackModes
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACK -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the backing member of the given field.intWhat to do on lifecycle callback exceptions.booleangetCallbacksBeforeListeners(int type) If callbacks are fired before listeners for the given event type.intThe default access type for base classes with ACCESS_UNKNOWN.intThe default identity type for unmapped classes without primary key fields.Return the list of fields inmetathat use field access, ornullif a list of fields is unobtainable.static StringgetFieldName(Member member) Return the field name for the given member.booleangetPersistentMembers(ClassMetaData meta, boolean ignoreTransient) Return the list of methods inmetathat use property access, ornullif a list of methods is unobtainable.Class<?> Return a runtime exception class to throw for un-implemented managed interface methods.booleanWhether to attempt to use the information from registered classes to populate metadata defaults.static booleanstatic booleanisBooleanGetter(Method method) Affirms if the given method matches the following signaturepublic boolean isXXX()public Boolean isXXX()booleanWhether the field in the object id class corresponding to a datastore id persistence-capable primary key field is the simple datastore id value of the related instance.booleanWhether declared interfaces of a class are treated as persistent types.protected abstract booleanisDefaultPersistent(ClassMetaData meta, Member member, String name, boolean ignoreTransient) Return true if the given member is persistent by default.static booleanAffirms if the given method signature matches bean-style getter method signature.
public T getXXX()where T is any non-void type.
or
public T isXXX()where T is boolean or Boolean.static booleanisNormalGetter(Method method) Affirms if the given method matches the following signaturepublic T getXXX()where T is any non-void type.protected booleanisReservedFieldName(String name) Returns true if the given field name is reserved for unmanaged fields.protected static booleanisUserDefined(Class<?> cls) Helper method; returns true if the given class appears to be user-defined.voidpopulate(ClassMetaData meta, int access) Populate the given metadata with default settings.voidpopulate(ClassMetaData meta, int access, boolean ignoreTransient) Populate the given metadata with default settings.protected voidpopulate(FieldMetaData fmd) voidsetCallbackMode(int mode) voidsetCallbackMode(int mode, boolean on) voidsetDataStoreObjectIdFieldUnwrapped(boolean unwrapped) voidsetDeclaredInterfacePersistent(boolean pers) voidsetDefaultAccessType(int access) The default access type for base classes with ACCESS_UNKNOWN.voidsetDefaultIdentityType(int identity) The default identity type for unmapped classes without primary key fields.voidsetIgnoreNonPersistent(boolean ignore) Whether to ignore members which are not persistent by default during metadata population.voidsetUsePCRegistry(boolean pcRegistry) Whether to attempt to use the information from registered classes to populate metadata defaults.static booleanstartsWith(String full, String head) Affirms if the given full string starts with the given head.
-
Constructor Details
-
AbstractMetaDataDefaults
public AbstractMetaDataDefaults()
-
-
Method Details
-
getUsePCRegistry
public boolean getUsePCRegistry()Whether to attempt to use the information from registered classes to populate metadata defaults. Defaults to true. -
setUsePCRegistry
public void setUsePCRegistry(boolean pcRegistry) Whether to attempt to use the information from registered classes to populate metadata defaults. Defaults to true. -
getDefaultAccessType
public int getDefaultAccessType()The default access type for base classes with ACCESS_UNKNOWN. ACCESS_FIELD by default.- Specified by:
getDefaultAccessTypein interfaceMetaDataDefaults
-
setDefaultAccessType
public void setDefaultAccessType(int access) The default access type for base classes with ACCESS_UNKNOWN. ACCESS_FIELD by default. -
getDefaultIdentityType
public int getDefaultIdentityType()The default identity type for unmapped classes without primary key fields. ID_UNKNOWN by default.- Specified by:
getDefaultIdentityTypein interfaceMetaDataDefaults
-
setDefaultIdentityType
public void setDefaultIdentityType(int identity) The default identity type for unmapped classes without primary key fields. ID_UNKNOWN by default. -
getCallbackMode
public int getCallbackMode()Description copied from interface:MetaDataDefaultsWhat to do on lifecycle callback exceptions.- Specified by:
getCallbackModein interfaceMetaDataDefaults
-
setCallbackMode
public void setCallbackMode(int mode) -
setCallbackMode
public void setCallbackMode(int mode, boolean on) -
getCallbacksBeforeListeners
public boolean getCallbacksBeforeListeners(int type) Description copied from interface:MetaDataDefaultsIf callbacks are fired before listeners for the given event type. Defaults to false.- Specified by:
getCallbacksBeforeListenersin interfaceMetaDataDefaults
-
isDeclaredInterfacePersistent
public boolean isDeclaredInterfacePersistent()Description copied from interface:MetaDataDefaultsWhether declared interfaces of a class are treated as persistent types. Defaults to true.- Specified by:
isDeclaredInterfacePersistentin interfaceMetaDataDefaults
-
setDeclaredInterfacePersistent
public void setDeclaredInterfacePersistent(boolean pers) -
isDataStoreObjectIdFieldUnwrapped
public boolean isDataStoreObjectIdFieldUnwrapped()Description copied from interface:MetaDataDefaultsWhether the field in the object id class corresponding to a datastore id persistence-capable primary key field is the simple datastore id value of the related instance. Defaults to false.- Specified by:
isDataStoreObjectIdFieldUnwrappedin interfaceMetaDataDefaults
-
setDataStoreObjectIdFieldUnwrapped
public void setDataStoreObjectIdFieldUnwrapped(boolean unwrapped) -
getIgnoreNonPersistent
public boolean getIgnoreNonPersistent() -
setIgnoreNonPersistent
public void setIgnoreNonPersistent(boolean ignore) Description copied from interface:MetaDataDefaultsWhether to ignore members which are not persistent by default during metadata population. Defaults to true.- Specified by:
setIgnoreNonPersistentin interfaceMetaDataDefaults
-
populate
Description copied from interface:MetaDataDefaultsPopulate the given metadata with default settings.- Specified by:
populatein interfaceMetaDataDefaults- Parameters:
access- access type constant fromClassMetaData
-
populate
Description copied from interface:MetaDataDefaultsPopulate the given metadata with default settings.- Specified by:
populatein interfaceMetaDataDefaults- Parameters:
access- access type constant fromClassMetaData
-
getPersistentMembers
-
populate
-
getFieldAccessNames
Return the list of fields inmetathat use field access, ornullif a list of fields is unobtainable. An empty list should be returned if the list of fields is obtainable, but there happens to be no field access inmeta. This is used for error reporting purposes only, so need not be efficient. This implementation returnsnull. -
getPropertyAccessNames
Return the list of methods inmetathat use property access, ornullif a list of methods is unobtainable. An empty list should be returned if the list of methods is obtainable, but there happens to be no property access inmeta. This is used for error reporting purposes only, so need not be efficient. This implementation returnsnull. -
getFieldName
Return the field name for the given member. This will only be invoked on members of the right type (field vs. method). Return null if the member cannot be managed. Default behavior: For fields, returns the field name. For getter methods, returns the minus "get" or "is" with the next letter lower-cased. For other methods, returns null.Note that this deliberately diverges from
java.beans.Introspector.decapitalize(), which leaves a name whose first two characters are both upper case untouched. Here the first character is lower-cased unconditionally, sogetAWord()andgetaWord()both yieldaWord, so that both accessor spellings map to a single property. Changing it would rename existing properties and their default column names. See OPENJPA-2993. -
isReservedFieldName
Returns true if the given field name is reserved for unmanaged fields. -
isDefaultPersistent
protected abstract boolean isDefaultPersistent(ClassMetaData meta, Member member, String name, boolean ignoreTransient) Return true if the given member is persistent by default. This will only be invoked on members of the right type (field vs. method). Returns false if member is static or final by default.- Parameters:
name- the field name fromgetFieldName(Member)
-
getBackingMember
Gets the backing member of the given field. If the field has not been assigned a backing member then get either the instance field or the getter method depending upon the access style of the defining class.
Defining class is used instead of declaring class because this method may be invoked during parsing phase when declaring metadata may not be available.- Specified by:
getBackingMemberin interfaceMetaDataDefaults
-
getUnimplementedExceptionType
Description copied from interface:MetaDataDefaultsReturn a runtime exception class to throw for un-implemented managed interface methods.- Specified by:
getUnimplementedExceptionTypein interfaceMetaDataDefaults
-
isUserDefined
Helper method; returns true if the given class appears to be user-defined. -
isNormalGetter
Affirms if the given method matches the following signaturepublic T getXXX()where T is any non-void type. -
isBooleanGetter
Affirms if the given method matches the following signaturepublic boolean isXXX()public Boolean isXXX()The case of the character following the
isprefix is deliberately not constrained. OpenJPA derives the property name by lower-casing the first character after the prefix (seegetFieldName(Member)), soisaBoolean()andisABoolean()both resolve to the propertyaBoolean. This mirrorsisNormalGetter(Method)andPersistenceMetaDataDefaults.isSetter, neither of which carries such a requirement; requiring an upper-case character here silently dropped JavaBeans-styleis<lowercase>()properties. See OPENJPA-2993. -
isGetter
Affirms if the given method signature matches bean-style getter method signature.
public T getXXX()where T is any non-void type.
or
public T isXXX()where T is boolean or Boolean. -
startsWith
-
isBoolean
-
toNames
-