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 childs
E - type of child
All Implemented Interfaces:
ListUpdator<P,​E>

public class EntityListUpdator<P extends TopiaEntity,​E extends TopiaEntity>
extends java.lang.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 
    Modifier and Type Field Description
    protected java.lang.reflect.Method addMethod  
    protected java.beans.PropertyDescriptor descriptor
    descriptor of the filed containing the childs
    protected java.lang.reflect.Method emptyMethod  
    protected java.lang.reflect.Method getMethod  
    protected java.lang.String propertyName
    name of the field containing the childs
    protected java.lang.reflect.Method removeAllMethod  
    protected java.lang.reflect.Method removeMethod  
    protected java.lang.reflect.Method sizeMethod  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected EntityListUpdator​(java.lang.Class<P> parentClass, java.lang.Class<E> childClass, java.lang.String propertyName)  
  • Method Summary

    Modifier and Type Method Description
    void addToList​(P parent, E bean)
    Add a erntity to his parent
    E getChild​(P parent, java.lang.String topiaId)
    Obtain a child from the entity given his id.
    java.util.Collection<E> getChilds​(P parent)
    Obtain the collection of childs from the entity.
    java.lang.String getPropertyName()
    Obtain the name of the property containing childs.
    protected static void invoke​(java.lang.reflect.Method m, java.lang.Object bean, java.lang.Object... args)  
    protected static <V> V invokeWithResult​(java.lang.reflect.Method m, java.lang.Object bean, java.lang.Object... args)  
    boolean isEmpty​(P parent)
    Tests if the given entity has some childs.
    static <P extends TopiaEntity,​ E extends TopiaEntity>
    EntityListUpdator<P,​E>
    newEntityListUpdator​(java.lang.Class<P> parentClass, java.lang.Class<E> childClass, java.lang.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, java.util.Collection<E> childs)
    Set the childs of an entity
    int size​(P parent)
    Obtain the number of childs for the given parent.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • propertyName

      protected java.lang.String propertyName
      name of the field containing the childs
    • descriptor

      protected java.beans.PropertyDescriptor descriptor
      descriptor of the filed containing the childs
    • getMethod

      protected java.lang.reflect.Method getMethod
    • addMethod

      protected java.lang.reflect.Method addMethod
    • removeMethod

      protected java.lang.reflect.Method removeMethod
    • removeAllMethod

      protected java.lang.reflect.Method removeAllMethod
    • sizeMethod

      protected java.lang.reflect.Method sizeMethod
    • emptyMethod

      protected java.lang.reflect.Method emptyMethod
  • Constructor Details

    • EntityListUpdator

      protected EntityListUpdator​(java.lang.Class<P> parentClass, java.lang.Class<E> childClass, java.lang.String propertyName)
  • Method Details