com.acsinet_solutions.util
Class ReflectionWrapper

java.lang.Object
  extended by com.acsinet_solutions.util.ReflectionWrapper

public final class ReflectionWrapper
extends java.lang.Object

Reflection Wrapper base class. Useful to avoid playing with reflection in common situations.

Author:
Santiago Arriaga

Method Summary
 void addValue(java.lang.Object bean, java.lang.String property, java.lang.Object value)
          Add the value for the given property in the given bean
 java.lang.Class getAdditionPropertyType(java.lang.String property)
          Get the addition property type
 java.lang.Object getIndexedValue(java.lang.Object bean, java.lang.String property, int pos)
          Get the indexed value for the given property in the given bean
 java.util.Set<java.lang.String> getReadOnlyPropertyNames()
          Get a list of the read only property names of the current class
 java.lang.Class getReadPropertyType(java.lang.String property)
          Get the read property type
 java.util.Set<java.lang.String> getReadWritePropertyNames()
          Get a list of the read/write property names of the current class
 java.lang.Object getValue(java.lang.Object bean, java.lang.String property)
          Get the value for the given property in the given bean
static ReflectionWrapper getWrapper(java.lang.Class c)
          ReflectionWrapper factory method
static ReflectionWrapper getWrapperFor(java.lang.Object obj)
          ReflectionWrapper factory method; Get a wrapper for the class implemented by the given object instance
 boolean hasAdditionProperty(java.lang.String name)
          Check if the current class has the given addition methods
 boolean hasIndexedReadProperty(java.lang.String name)
          Check if the current class has the given indexed read property
 boolean hasReadProperty(java.lang.String name)
          Check if the current class has the given read property
 boolean hasReadWriteProperty(java.lang.String name)
          Check if the current class has both read and write properties for the given name
 boolean hasWriteProperty(java.lang.String name)
          Check if the current class has the given write property
 void removeValue(java.lang.Object bean, java.lang.String property, java.lang.Object value)
          Remove the value for the given property in the given bean
 void setValue(java.lang.Object bean, java.lang.String property, java.lang.Object value)
          Set the value for the given property in the given bean
 void setValueByType(java.lang.Object bean, java.lang.Class propertyType, java.lang.Object value)
          Method wire.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getWrapper

public static final ReflectionWrapper getWrapper(java.lang.Class c)
ReflectionWrapper factory method

Parameters:
c - A not-null Class instance
Returns:
A not-null ReflectionWrapper instance

getWrapperFor

public static final ReflectionWrapper getWrapperFor(java.lang.Object obj)
ReflectionWrapper factory method; Get a wrapper for the class implemented by the given object instance

Parameters:
obj - A not-null Object instance
Returns:
A not-null ReflectionWrapper instance

getReadWritePropertyNames

public final java.util.Set<java.lang.String> getReadWritePropertyNames()
Get a list of the read/write property names of the current class

Returns:
A not-null maybe-empty Set of not-null not-empty String instances

getReadOnlyPropertyNames

public final java.util.Set<java.lang.String> getReadOnlyPropertyNames()
Get a list of the read only property names of the current class

Returns:
A not-null maybe-empty Set of not-null not-empty String instances

hasReadProperty

public final boolean hasReadProperty(java.lang.String name)
Check if the current class has the given read property

Parameters:
name - A not-null String instance
Returns:
true if the current class has the given property; false otherwise

getReadPropertyType

public final java.lang.Class getReadPropertyType(java.lang.String property)
Get the read property type

Parameters:
property - The not-null not-empty Property name
Returns:
A not-null Class instance

hasWriteProperty

public final boolean hasWriteProperty(java.lang.String name)
Check if the current class has the given write property

Parameters:
name - A not-null String instance
Returns:
true if the current class has the given property; false otherwise

hasReadWriteProperty

public final boolean hasReadWriteProperty(java.lang.String name)
Check if the current class has both read and write properties for the given name

Parameters:
name - A not-null String instance
Returns:
true if the current class has both read and write property; false otherwise

hasIndexedReadProperty

public final boolean hasIndexedReadProperty(java.lang.String name)
Check if the current class has the given indexed read property

Parameters:
name - A not-null String instance
Returns:
true if the current class has the given property; false otherwise

hasAdditionProperty

public final boolean hasAdditionProperty(java.lang.String name)
Check if the current class has the given addition methods

Parameters:
name - A not-null String instance
Returns:
true if the current class has the given addition property; false otherwise

getAdditionPropertyType

public final java.lang.Class getAdditionPropertyType(java.lang.String property)
Get the addition property type

Parameters:
property - The not-null not-empty Property name
Returns:
A not-null Class instance

getValue

public final java.lang.Object getValue(java.lang.Object bean,
                                       java.lang.String property)
Get the value for the given property in the given bean

Parameters:
bean - A not-null Object instance
property - A not-null String instance

getIndexedValue

public final java.lang.Object getIndexedValue(java.lang.Object bean,
                                              java.lang.String property,
                                              int pos)
Get the indexed value for the given property in the given bean

Parameters:
bean - A not-null Object instance
property - A not-null String instance

setValue

public final void setValue(java.lang.Object bean,
                           java.lang.String property,
                           java.lang.Object value)
Set the value for the given property in the given bean

Parameters:
bean - A not-null Object instance
property - A not-null String instance
value - A maybe-null property to set

addValue

public final void addValue(java.lang.Object bean,
                           java.lang.String property,
                           java.lang.Object value)
Add the value for the given property in the given bean

Parameters:
bean - A not-null Object instance
property - A not-null String instance
value - A maybe-null property to set

removeValue

public final void removeValue(java.lang.Object bean,
                              java.lang.String property,
                              java.lang.Object value)
Remove the value for the given property in the given bean

Parameters:
bean - A not-null Object instance
property - A not-null String instance
value - A maybe-null property to set

setValueByType

public void setValueByType(java.lang.Object bean,
                           java.lang.Class propertyType,
                           java.lang.Object value)
Method wire.

Parameters:
propertyType -
source -