Class EntityListUpdator<P extends TopiaEntity,E extends TopiaEntity>
java.lang.Object
org.nuiton.topia.persistence.util.EntityListUpdator<P,E>
- Type Parameters:
P- type of parent of childsE- type of child
- All Implemented Interfaces:
ListUpdator<P,E>
public class EntityListUpdator<P extends TopiaEntity,E extends TopiaEntity>
extends Object
implements ListUpdator<P,E>
A implementation of
ListUpdator for TopiaEntity type.
Some factory methods are defined to simplify the generic cast, prefer used them
instead of the (protected) constructor.- Author:
- tchemit <chemit@codelutin.com>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a erntity to his parentObtain a child from the entity given his id.Obtain the collection of childs from the entity.Obtain the name of the property containing childs.protected static voidprotected static <V> VinvokeWithResult(Method m, Object bean, Object... args) booleanTests if the given entity has some childs.static <P extends TopiaEntity,E extends TopiaEntity>
EntityListUpdator<P,E> newEntityListUpdator(Class<P> parentClass, Class<E> childClass, String propertyName) voidRemove all childs of the given parent.voidremoveFromList(P parent, E bean) Remove from a prent entity a given child.voidsetChilds(P parent, Collection<E> childs) Set the childs of an entityintObtain the number of childs for the given parent.
-
Field Details
-
propertyName
name of the field containing the childs -
descriptor
descriptor of the filed containing the childs -
getMethod
-
addMethod
-
removeMethod
-
removeAllMethod
-
sizeMethod
-
emptyMethod
-
-
Constructor Details
-
EntityListUpdator
-
-
Method Details
-
newEntityListUpdator
public static <P extends TopiaEntity,E extends TopiaEntity> EntityListUpdator<P,E> newEntityListUpdator(Class<P> parentClass, Class<E> childClass, String propertyName) -
getPropertyName
Description copied from interface:ListUpdatorObtain the name of the property containing childs.- Specified by:
getPropertyNamein interfaceListUpdator<P extends TopiaEntity,E extends TopiaEntity> - Returns:
- the name of the property containing childs.
-
getChild
Description copied from interface:ListUpdatorObtain a child from the entity given his id.- Specified by:
getChildin interfaceListUpdator<P extends TopiaEntity,E extends TopiaEntity> - Parameters:
parent- the entity to querytopiaId- the id of the researched child entity.- Returns:
- the child entity or
null, if not found.
-
getChilds
Description copied from interface:ListUpdatorObtain the collection of childs from the entity.- Specified by:
getChildsin interfaceListUpdator<P extends TopiaEntity,E extends TopiaEntity> - Parameters:
parent- the entity to query.- Returns:
- the collection of childs
-
size
Description copied from interface:ListUpdatorObtain the number of childs for the given parent.- Specified by:
sizein interfaceListUpdator<P extends TopiaEntity,E extends TopiaEntity> - Parameters:
parent- the entity to query- Returns:
- the number of childs for the given entity
-
isEmpty
Description copied from interface:ListUpdatorTests if the given entity has some childs.- Specified by:
isEmptyin interfaceListUpdator<P extends TopiaEntity,E extends TopiaEntity> - Parameters:
parent- the entity to query- Returns:
trueis the given parent has no child.
-
setChilds
Description copied from interface:ListUpdatorSet the childs of an entity- Specified by:
setChildsin interfaceListUpdator<P extends TopiaEntity,E extends TopiaEntity> - Parameters:
parent- the entity to be settedchilds- the collection of childs to set.
-
addToList
Description copied from interface:ListUpdatorAdd a erntity to his parent- Specified by:
addToListin interfaceListUpdator<P extends TopiaEntity,E extends TopiaEntity> - Parameters:
parent- the entity to modifiybean- the entity to add in parent.- Throws:
TopiaException- if any db problem while operation
-
removeFromList
Description copied from interface:ListUpdatorRemove from a prent entity a given child.- Specified by:
removeFromListin interfaceListUpdator<P extends TopiaEntity,E extends TopiaEntity> - Parameters:
parent- the entity to modifiybean- the child to remove.- Throws:
TopiaException- if any pb while operation.
-
removeAll
Description copied from interface:ListUpdatorRemove all childs of the given parent.- Specified by:
removeAllin interfaceListUpdator<P extends TopiaEntity,E extends TopiaEntity> - Parameters:
parent- the entity to modify
-
invoke
-
invokeWithResult
-