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:
Serializable
Group 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
The class that this group is for.static final String
Names of the fields/properties of the class that are part of this group.static final String
private String
Name of the group.private NucleusContext
Context.private Collection
<FetchPlan> FetchPlans listening to this group for changes.private boolean
Whether the postLoad callback is to be called when this group is loaded.Map of recursion depth, keyed by the member name.static final String
private static final long
private boolean
Whether this group can be modified. -
Constructor Summary
ConstructorsConstructorDescriptionFetchGroup
(FetchGroup<T> grp) Constructor to take a copy of the supplied group, but modifiable.FetchGroup
(NucleusContext nucleusCtx, String name, Class<T> cls) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddCategory
(String categoryName) Convenience method to add the members for the specified category.Method to add a field of the class to the fetch group.addMembers
(String[] members) private void
assertNotMember
(String memberName) Method to throw an exception if the specified member is not a member of this class.private void
Method to throw an exception if the fetch group is currently unmodifiable.void
deregisterListener
(FetchPlan plan) Method to deregister a listener for changes to this FetchGroup.void
Method to disconnect this fetch group from all listeners since the group is removed from use.boolean
private String[]
getMemberNamesForCategory
(String categoryName) Convenience accessor to return the member names for the specified category name.private AbstractClassMetaData
getName()
Accessor for the group name.boolean
Accessor for whether to call postLoad when this group is loaded.int
getRecursionDepth
(String memberName) Accessor for the recursion depth for the specified field/property.getType()
Accessor for the class that this group is for.int
hashCode()
boolean
Accessor for modifiability status of this group.private void
Method to notify all FetchPlan listeners that this group has changed.void
registerListener
(FetchPlan plan) Method to register a listener for changes to this FetchGroup.removeCategory
(String categoryName) Convenience method to remove the members for the specified category.removeMember
(String memberName) Method to remove a field of the class from the fetch group.removeMembers
(String[] members) void
setPostLoad
(boolean postLoad) Mutator for whether the postLoad callback should be called on loading this fetch group.setRecursionDepth
(String memberName, int recursionDepth) Method to set the recursion depth for the specified field/property.Method to make the group unmodifiable.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
DEFAULT
- See Also:
-
RELATIONSHIP
- See Also:
-
MULTIVALUED
- See Also:
-
BASIC
- See Also:
-
ALL
- See Also:
-
nucleusCtx
Context. -
name
Name of the group. -
cls
The class that this group is for. -
postLoad
private boolean postLoadWhether the postLoad callback is to be called when this group is loaded. -
memberNames
Names of the fields/properties of the class that are part of this group. -
recursionDepthByMemberName
Map of recursion depth, keyed by the member name. Only has entries when not using default. -
planListeners
FetchPlans listening to this group for changes. -
unmodifiable
private boolean unmodifiableWhether this group can be modified.
-
-
Constructor Details
-
FetchGroup
Constructor.- Parameters:
nucleusCtx
- Contextname
- Name of the groupcls
- The class
-
FetchGroup
Constructor to take a copy of the supplied group, but modifiable.- Parameters:
grp
- The existing group
-
-
Method Details
-
getName
Accessor for the group name.- Returns:
- Name of the group
-
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
Accessor for the recursion depth for the specified field/property.- Parameters:
memberName
- Name of field/property- Returns:
- The recursion depth
-
setRecursionDepth
Method to set the recursion depth for the specified field/property.- Parameters:
memberName
- Name of field/propertyrecursionDepth
- Recursion depth- Returns:
- The fetch group
-
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
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
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
Convenience accessor to return the member names for the specified category name.- Parameters:
categoryName
- Name of the category- Returns:
- The member names
-
getMembers
-
addMember
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
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
-
removeMembers
-
notifyListeners
private void notifyListeners()Method to notify all FetchPlan listeners that this group has changed. -
getListenerFPs
-
registerListener
Method to register a listener for changes to this FetchGroup.- Parameters:
plan
- The FetchPlan that is listening
-
deregisterListener
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
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
-
equals
-
hashCode
public int hashCode() -
toString
-