net.sf.beanlib.hibernate
Class HibernatePropertyFilter

java.lang.Object
  extended by net.sf.beanlib.hibernate.HibernatePropertyFilter
All Implemented Interfaces:
PropertyFilter

public class HibernatePropertyFilter
extends Object
implements PropertyFilter

A default implementation used to determine if a Hibernate property that follows the JavaBean getter/setter convention should be propagated. Each propagation decision can be controlled by specifying

Author:
Joe D. Velopar

Field Summary
private  String applicationPackagePrefix
          An entity bean under a package with a name that matches this prefix will be included for replication, eagerly fetched if necessary.
private  Set<? extends CollectionPropertyName<?>> collectionPropertyNameSet
          The set of collection and map properties that will be replicated, eagerly fetching if necessary.
private  Set<Class<?>> entityBeanClassSet
          The set of entity bean classes for matching properties that will be replicated, eagerly fetching if necessary.
private  PropertyFilter vetoer
          Used to veto the propagation of a property.
 
Constructor Summary
HibernatePropertyFilter()
          Constructs with the default behavior of replicating all properties recursively.
HibernatePropertyFilter(Set<Class<?>> entityBeanClassSet, Set<? extends CollectionPropertyName<?>> collectionPropertyNameSet, PropertyFilter vetoer)
          Constructs with the specified options of controlling what to be replicated and what not.
HibernatePropertyFilter(String applicationPackagePrefix)
          Constructs with an application package prefix.
HibernatePropertyFilter(String applicationPackagePrefix, Set<Class<?>> entityBeanClassSet, Set<? extends CollectionPropertyName<?>> collectionPropertyNameSet, PropertyFilter vetoer)
          Constructs with the specified options of controlling what to be replicated and what not.
 
Method Summary
private  boolean checkCollectionProperty(String propertyName, Method readerMethod)
           
 Set<CollectionPropertyName<?>> getCollectionPropertyNameSet()
          Returns the configured set of collection and map properties that are to be replicated, eagerly fetching if necessary; null if all collection and map properties are to be replicated; or empty if no collection nor map properties are to be replicated.
 Set<Class<?>> getEntityBeanClassSet()
          Returns the configured set of entity bean classes for matching properties that will be replicated, eagerly fetching if necessary; null if all entity bean classes are to be replicated; or empty if no entity bean class is to be replicated.
 PropertyFilter getVetoer()
          Returns the vetoer configured for vetoing the propagation of a property.
 boolean isApplicationClass(Class<?> c)
          Returns true iff c is an application class.
 boolean propagate(String propertyName, Method readerMethod)
          Returns true if the given JavaBean property should be propagated; false otherwise.
 boolean propagateImpl(String propertyName, Method readerMethod)
           
 HibernatePropertyFilter withCollectionPropertyNameSet(Set<? extends CollectionPropertyName<?>> collectionPropertyNameSet)
          Used to configure the set of collection and map properties that will be replicated, eagerly fetching if necessary.
 HibernatePropertyFilter withEntityBeanClassSet(Set<Class<?>> entityBeanClassSet)
          Used to configure the set of entity bean classes for matching properties that will be replicated, eagerly fetching if necessary.
 HibernatePropertyFilter withVetoer(PropertyFilter vetoer)
          Used to configure a vetoer for vetoing the propagation of a property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entityBeanClassSet

private Set<Class<?>> entityBeanClassSet
The set of entity bean classes for matching properties that will be replicated, eagerly fetching if necessary. Null means all whereas empty means none.


collectionPropertyNameSet

private Set<? extends CollectionPropertyName<?>> collectionPropertyNameSet
The set of collection and map properties that will be replicated, eagerly fetching if necessary. Null means all whereas empty means none.


vetoer

private PropertyFilter vetoer
Used to veto the propagation of a property.


applicationPackagePrefix

private final String applicationPackagePrefix
An entity bean under a package with a name that matches this prefix will be included for replication, eagerly fetched if necessary. Otherwise, the semantics of entityBeanClassSet applies.

Constructor Detail

HibernatePropertyFilter

public HibernatePropertyFilter(Set<Class<?>> entityBeanClassSet,
                               Set<? extends CollectionPropertyName<?>> collectionPropertyNameSet,
                               PropertyFilter vetoer)
Constructs with the specified options of controlling what to be replicated and what not.

Parameters:
entityBeanClassSet - The set of entity bean classes for matching properties that will be replicated, eagerly fetching if necessary. Null means all whereas empty means none.
collectionPropertyNameSet - The set of collection and map properties that will be replicated, eagerly fetching if necessary. Null means all whereas empty means none.
vetoer - used to veto the propagation of a JavaBean property.

HibernatePropertyFilter

public HibernatePropertyFilter(String applicationPackagePrefix,
                               Set<Class<?>> entityBeanClassSet,
                               Set<? extends CollectionPropertyName<?>> collectionPropertyNameSet,
                               PropertyFilter vetoer)
Constructs with the specified options of controlling what to be replicated and what not.

Parameters:
applicationPackagePrefix - An entity bean under a package with a name that matches this prefix will be included for replication, eagerly fetched if necessary. Otherwise, the semantics of entityBeanClassSet applies.
entityBeanClassSet - The set of entity bean classes for matching properties that will be replicated, eagerly fetching if necessary. Null means all whereas empty means none.
collectionPropertyNameSet - The set of collection and map properties that will be replicated, eagerly fetching if necessary. Null means all whereas empty means none.
vetoer - used to veto the propagation of a JavaBean property.

HibernatePropertyFilter

public HibernatePropertyFilter()
Constructs with the default behavior of replicating all properties recursively.


HibernatePropertyFilter

public HibernatePropertyFilter(String applicationPackagePrefix)
Constructs with an application package prefix.

Parameters:
applicationPackagePrefix - An entity bean under a package with a name that matches this prefix will be included for replication, eagerly fetched if necessary. Otherwise, the semantics of entityBeanClassSet applies.
Method Detail

getEntityBeanClassSet

public Set<Class<?>> getEntityBeanClassSet()
Returns the configured set of entity bean classes for matching properties that will be replicated, eagerly fetching if necessary; null if all entity bean classes are to be replicated; or empty if no entity bean class is to be replicated.


withEntityBeanClassSet

public HibernatePropertyFilter withEntityBeanClassSet(Set<Class<?>> entityBeanClassSet)
Used to configure the set of entity bean classes for matching properties that will be replicated, eagerly fetching if necessary.

Parameters:
entityBeanClassSet - the set of entity bean classes for matching properties that will be replicated, eagerly fetching if necessary. null if all entity bean classes are to be replicated; or empty if no entity bean class is to be replicated.
Returns:
the current instance for method chaining purposes.

getCollectionPropertyNameSet

public Set<CollectionPropertyName<?>> getCollectionPropertyNameSet()
Returns the configured set of collection and map properties that are to be replicated, eagerly fetching if necessary; null if all collection and map properties are to be replicated; or empty if no collection nor map properties are to be replicated.


withCollectionPropertyNameSet

public HibernatePropertyFilter withCollectionPropertyNameSet(Set<? extends CollectionPropertyName<?>> collectionPropertyNameSet)
Used to configure the set of collection and map properties that will be replicated, eagerly fetching if necessary.

Parameters:
collectionPropertyNameSet - set of collection and map properties that will be replicated, eagerly fetching if necessary; null if all collection and map properties are to be replicated; or empty if no collection nor map properties are to be replicated.
Returns:
the current instance for method chaining purposes.

getVetoer

public PropertyFilter getVetoer()
Returns the vetoer configured for vetoing the propagation of a property.


withVetoer

public HibernatePropertyFilter withVetoer(PropertyFilter vetoer)
Used to configure a vetoer for vetoing the propagation of a property.

Returns:
the current instance for method chaining purposes.

propagate

public boolean propagate(String propertyName,
                         Method readerMethod)
Description copied from interface: PropertyFilter
Returns true if the given JavaBean property should be propagated; false otherwise.

Specified by:
propagate in interface PropertyFilter
Parameters:
propertyName - JavaBean property name.
readerMethod - reader method of the JavaBean property name.
Returns:
true if the given JavaBean property should be propagated.

propagateImpl

public boolean propagateImpl(String propertyName,
                             Method readerMethod)

checkCollectionProperty

private boolean checkCollectionProperty(String propertyName,
                                        Method readerMethod)

isApplicationClass

public boolean isApplicationClass(Class<?> c)
Returns true iff c is an application class.