Package org.datanucleus
Class FetchGroup<T>
- java.lang.Object
-
- org.datanucleus.FetchGroup<T>
-
- Type Parameters:
T- Class that this FetchGroup is for
- All Implemented Interfaces:
java.io.Serializable
public class FetchGroup<T> extends java.lang.Object implements java.io.SerializableGroup of fields for fetching, to be used by a FetchPlan. Defined at runtime, via the API (aka dynamic fetch group). Shared by FetchPlan's, so can be used by multiple threads.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringALLstatic java.lang.StringBASICprivate java.lang.Class<T>clsThe class that this group is for.static java.lang.StringDEFAULTprivate java.util.Set<java.lang.String>memberNamesNames of the fields/properties of the class that are part of this group.static java.lang.StringMULTIVALUEDprivate java.lang.StringnameName of the group.private NucleusContextnucleusCtxContext.private java.util.Collection<FetchPlan>planListenersFetchPlans listening to this group for changes.private booleanpostLoadWhether the postLoad callback is to be called when this group is loaded.private java.util.Map<java.lang.String,java.lang.Integer>recursionDepthByMemberNameMap of recursion depth, keyed by the member name.static java.lang.StringRELATIONSHIPprivate static longserialVersionUIDprivate booleanunmodifiableWhether this group can be modified.
-
Constructor Summary
Constructors Constructor Description FetchGroup(FetchGroup<T> grp)Constructor to take a copy of the supplied group, but modifiable.FetchGroup(NucleusContext nucleusCtx, java.lang.String name, java.lang.Class<T> cls)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FetchGroupaddCategory(java.lang.String categoryName)Convenience method to add the members for the specified category.FetchGroupaddMember(java.lang.String memberName)Method to add a field of the class to the fetch group.FetchGroupaddMembers(java.lang.String[] members)private voidassertNotMember(java.lang.String memberName)Method to throw an exception if the specified member is not a member of this class.private voidassertUnmodifiable()Method to throw an exception if the fetch group is currently unmodifiable.voidderegisterListener(FetchPlan plan)Method to deregister a listener for changes to this FetchGroup.voiddisconnectFromListeners()Method to disconnect this fetch group from all listeners since the group is removed from use.booleanequals(java.lang.Object obj)java.util.Collection<FetchPlan>getListenerFPs()private java.lang.String[]getMemberNamesForCategory(java.lang.String categoryName)Convenience accessor to return the member names for the specified category name.java.util.Set<java.lang.String>getMembers()private AbstractClassMetaDatagetMetaDataForClass()java.lang.StringgetName()Accessor for the group name.booleangetPostLoad()Accessor for whether to call postLoad when this group is loaded.intgetRecursionDepth(java.lang.String memberName)Accessor for the recursion depth for the specified field/property.java.lang.Class<T>getType()Accessor for the class that this group is for.inthashCode()booleanisUnmodifiable()Accessor for modifiability status of this group.private voidnotifyListeners()Method to notify all FetchPlan listeners that this group has changed.voidregisterListener(FetchPlan plan)Method to register a listener for changes to this FetchGroup.FetchGroupremoveCategory(java.lang.String categoryName)Convenience method to remove the members for the specified category.FetchGroupremoveMember(java.lang.String memberName)Method to remove a field of the class from the fetch group.FetchGroupremoveMembers(java.lang.String[] members)voidsetPostLoad(boolean postLoad)Mutator for whether the postLoad callback should be called on loading this fetch group.FetchGroupsetRecursionDepth(java.lang.String memberName, int recursionDepth)Method to set the recursion depth for the specified field/property.FetchGroupsetUnmodifiable()Method to make the group unmodifiable.java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DEFAULT
public static final java.lang.String DEFAULT
- See Also:
- Constant Field Values
-
RELATIONSHIP
public static final java.lang.String RELATIONSHIP
- See Also:
- Constant Field Values
-
MULTIVALUED
public static final java.lang.String MULTIVALUED
- See Also:
- Constant Field Values
-
BASIC
public static final java.lang.String BASIC
- See Also:
- Constant Field Values
-
ALL
public static final java.lang.String ALL
- See Also:
- Constant Field Values
-
nucleusCtx
private NucleusContext nucleusCtx
Context.
-
name
private java.lang.String name
Name of the group.
-
cls
private java.lang.Class<T> cls
The class that this group is for.
-
postLoad
private boolean postLoad
Whether the postLoad callback is to be called when this group is loaded.
-
memberNames
private java.util.Set<java.lang.String> memberNames
Names of the fields/properties of the class that are part of this group.
-
recursionDepthByMemberName
private java.util.Map<java.lang.String,java.lang.Integer> recursionDepthByMemberName
Map of recursion depth, keyed by the member name. Only has entries when not using default.
-
planListeners
private java.util.Collection<FetchPlan> planListeners
FetchPlans listening to this group for changes.
-
unmodifiable
private boolean unmodifiable
Whether this group can be modified.
-
-
Constructor Detail
-
FetchGroup
public FetchGroup(NucleusContext nucleusCtx, java.lang.String name, java.lang.Class<T> cls)
Constructor.- Parameters:
nucleusCtx- Contextname- Name of the groupcls- The class
-
FetchGroup
public FetchGroup(FetchGroup<T> grp)
Constructor to take a copy of the supplied group, but modifiable.- Parameters:
grp- The existing group
-
-
Method Detail
-
getName
public java.lang.String getName()
Accessor for the group name.- Returns:
- Name of the group
-
getType
public java.lang.Class<T> getType()
Accessor for the class that this group is for.- Returns:
- the class
-
setPostLoad
public void setPostLoad(boolean postLoad)
Mutator for whether the postLoad callback should be called on loading this fetch group.- Parameters:
postLoad- Whether the postLoad callback should be called.
-
getPostLoad
public boolean getPostLoad()
Accessor for whether to call postLoad when this group is loaded.- Returns:
- Whether to call postLoad
-
getRecursionDepth
public int getRecursionDepth(java.lang.String memberName)
Accessor for the recursion depth for the specified field/property.- Parameters:
memberName- Name of field/property- Returns:
- The recursion depth
-
setRecursionDepth
public FetchGroup setRecursionDepth(java.lang.String memberName, int recursionDepth)
Method to set the recursion depth for the specified field/property.- Parameters:
memberName- Name of field/propertyrecursionDepth- Recursion depth- Returns:
- The fetch group
-
setUnmodifiable
public FetchGroup setUnmodifiable()
Method to make the group unmodifiable. Once unmodifiable it cannot be made modifiable again.- Returns:
- This group
-
isUnmodifiable
public boolean isUnmodifiable()
Accessor for modifiability status of this group.- Returns:
- Whether it is no longer modifiable
-
addCategory
public FetchGroup addCategory(java.lang.String categoryName)
Convenience method to add the members for the specified category. Supports the categories defined in the JDO spec.- Parameters:
categoryName- Name of the category- Returns:
- This group
-
removeCategory
public FetchGroup removeCategory(java.lang.String categoryName)
Convenience method to remove the members for the specified category. Supports the categories defined in the JDO spec.- Parameters:
categoryName- Name of the category- Returns:
- This group
-
getMemberNamesForCategory
private java.lang.String[] getMemberNamesForCategory(java.lang.String categoryName)
Convenience accessor to return the member names for the specified category name.- Parameters:
categoryName- Name of the category- Returns:
- The member names
-
getMembers
public java.util.Set<java.lang.String> getMembers()
-
addMember
public FetchGroup addMember(java.lang.String memberName)
Method to add a field of the class to the fetch group.- Parameters:
memberName- Name of the field/property- Returns:
- This FetchGroup
- Throws:
NucleusUserException- if the field/property doesn't exist for this class
-
removeMember
public FetchGroup removeMember(java.lang.String memberName)
Method to remove a field of the class from the fetch group.- Parameters:
memberName- Name of the field/property- Returns:
- This FetchGroup
- Throws:
NucleusUserException- if the field/property doesn't exist for this class
-
addMembers
public FetchGroup addMembers(java.lang.String[] members)
-
removeMembers
public FetchGroup removeMembers(java.lang.String[] members)
-
notifyListeners
private void notifyListeners()
Method to notify all FetchPlan listeners that this group has changed.
-
getListenerFPs
public java.util.Collection<FetchPlan> getListenerFPs()
-
registerListener
public void registerListener(FetchPlan plan)
Method to register a listener for changes to this FetchGroup.- Parameters:
plan- The FetchPlan that is listening
-
deregisterListener
public void deregisterListener(FetchPlan plan)
Method to deregister a listener for changes to this FetchGroup.- Parameters:
plan- The FetchPlan that is no longer listening
-
disconnectFromListeners
public void disconnectFromListeners()
Method to disconnect this fetch group from all listeners since the group is removed from use.
-
assertUnmodifiable
private void assertUnmodifiable()
Method to throw an exception if the fetch group is currently unmodifiable.
-
assertNotMember
private void assertNotMember(java.lang.String memberName)
Method to throw an exception if the specified member is not a member of this class.- Parameters:
memberName- Name of the field/property- Throws:
NucleusUserException
-
getMetaDataForClass
private AbstractClassMetaData getMetaDataForClass()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-