P
- type of parent of childsE
- type of childpublic class EntityListUpdator<P extends TopiaEntity,E extends TopiaEntity> extends Object implements ListUpdator<P,E>
ListUpdator
for TopiaEntity
type.
Some factory methods are defined to simplify the generic cast, prefer used them
instead of the (protected) constructor.Modifier and Type | Field and Description |
---|---|
protected Method |
addMethod |
protected PropertyDescriptor |
descriptor
descriptor of the filed containing the childs
|
protected Method |
emptyMethod |
protected Method |
getMethod |
protected String |
propertyName
name of the field containing the childs
|
protected Method |
removeAllMethod |
protected Method |
removeMethod |
protected Method |
sizeMethod |
Modifier | Constructor and Description |
---|---|
protected |
EntityListUpdator(Class<P> parentClass,
Class<E> childClass,
String propertyName) |
Modifier and Type | Method and Description |
---|---|
void |
addToList(P parent,
E bean)
Add a erntity to his parent
|
E |
getChild(P parent,
String topiaId)
Obtain a child from the entity given his id.
|
Collection<E> |
getChilds(P parent)
Obtain the collection of childs from the entity.
|
String |
getPropertyName()
Obtain the name of the property containing childs.
|
protected static void |
invoke(Method m,
Object bean,
Object... args) |
protected static <V> V |
invokeWithResult(Method m,
Object bean,
Object... args) |
boolean |
isEmpty(P parent)
Tests if the given entity has some childs.
|
static <P extends TopiaEntity,E extends TopiaEntity> |
newEntityListUpdator(Class<P> parentClass,
Class<E> childClass,
String propertyName) |
void |
removeAll(P parent)
Remove all childs of the given parent.
|
void |
removeFromList(P parent,
E bean)
Remove from a prent entity a given child.
|
void |
setChilds(P parent,
Collection<E> childs)
Set the childs of an entity
|
int |
size(P parent)
Obtain the number of childs for the given parent.
|
protected String propertyName
protected PropertyDescriptor descriptor
protected Method getMethod
protected Method addMethod
protected Method removeMethod
protected Method removeAllMethod
protected Method sizeMethod
protected Method emptyMethod
public static <P extends TopiaEntity,E extends TopiaEntity> EntityListUpdator<P,E> newEntityListUpdator(Class<P> parentClass, Class<E> childClass, String propertyName)
public String getPropertyName()
ListUpdator
getPropertyName
in interface ListUpdator<P extends TopiaEntity,E extends TopiaEntity>
public E getChild(P parent, String topiaId)
ListUpdator
getChild
in interface ListUpdator<P extends TopiaEntity,E extends TopiaEntity>
parent
- the entity to querytopiaId
- the id of the researched child entity.null
, if not found.public Collection<E> getChilds(P parent)
ListUpdator
getChilds
in interface ListUpdator<P extends TopiaEntity,E extends TopiaEntity>
parent
- the entity to query.public int size(P parent)
ListUpdator
size
in interface ListUpdator<P extends TopiaEntity,E extends TopiaEntity>
parent
- the entity to querypublic boolean isEmpty(P parent)
ListUpdator
isEmpty
in interface ListUpdator<P extends TopiaEntity,E extends TopiaEntity>
parent
- the entity to querytrue
is the given parent has no child.public void setChilds(P parent, Collection<E> childs)
ListUpdator
setChilds
in interface ListUpdator<P extends TopiaEntity,E extends TopiaEntity>
parent
- the entity to be settedchilds
- the collection of childs to set.public void addToList(P parent, E bean) throws TopiaException
ListUpdator
addToList
in interface ListUpdator<P extends TopiaEntity,E extends TopiaEntity>
parent
- the entity to modifiybean
- the entity to add in parent.TopiaException
- if any db problem while operationpublic void removeFromList(P parent, E bean) throws TopiaException
ListUpdator
removeFromList
in interface ListUpdator<P extends TopiaEntity,E extends TopiaEntity>
parent
- the entity to modifiybean
- the child to remove.TopiaException
- if any pb while operation.public void removeAll(P parent)
ListUpdator
removeAll
in interface ListUpdator<P extends TopiaEntity,E extends TopiaEntity>
parent
- the entity to modifyCopyright © 2004–2022 Code Lutin. All rights reserved.