org.omnaest.utils.beans.result
Class BeanPropertyAccessor<B>

java.lang.Object
  extended by org.omnaest.utils.beans.result.BeanPropertyAccessor<B>
Type Parameters:
B - Java Bean type

public class BeanPropertyAccessor<B>
extends Object

Java Bean property access object for Methods and Field of a special Java Bean type.

Author:
Omnaest

Field Summary
protected  Class<B> beanClass
           
protected  Field field
           
protected  Method methodGetter
           
protected  Method methodSetter
           
protected  String propertyName
           
 
Constructor Summary
BeanPropertyAccessor(Field field, Method methodGetter, Method methodSetter, String propertyName, Class<B> beanClass)
           
 
Method Summary
 boolean copyPropertyValue(B beanSource, B beanDestination)
          Copies the value of one Java Bean for the underlying Java Bean property of this BeanPropertyAccessor to another Java Bean.
 Class<?> determinePropertyType()
          Determines the Class type for the property.
 Class<?> getBeanClass()
           
 Field getField()
           
protected  Method getMethod()
           
 Method getMethodGetter()
           
 Method getMethodSetter()
           
 String getPropertyName()
           
 Object getPropertyValue(B bean)
          Returns the property value for the underlying Java Bean property from the given Java Bean object.
 boolean hasGetter()
          Returns true, if the method has no parameters but a return type.
 boolean hasGetterAndSetter()
          Returns true, if the underlying Field has a getter and a setter method.
 boolean hasGetterOrSetter()
          Returns true, if the underlying Field has at least a getter or a setter method or both available.
 boolean hasSetter()
          Is true, if a method has only one parameter and begins with "set".
static
<B> BeanPropertyAccessor<B>
merge(BeanPropertyAccessor<B> beanPropertyAccessorA, BeanPropertyAccessor<B> beanPropertyAccessorB)
          Merges two BeanPropertyAccessor instances into one if the underlying Class and property are equal.
 boolean setPropertyValue(B bean, Object value)
          Sets the property value for the underlying Java Bean property for the given Java Bean object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

propertyName

protected String propertyName

field

protected Field field

methodGetter

protected Method methodGetter

methodSetter

protected Method methodSetter

beanClass

protected Class<B> beanClass
Constructor Detail

BeanPropertyAccessor

public BeanPropertyAccessor(Field field,
                            Method methodGetter,
                            Method methodSetter,
                            String propertyName,
                            Class<B> beanClass)
Method Detail

copyPropertyValue

public boolean copyPropertyValue(B beanSource,
                                 B beanDestination)
Copies the value of one Java Bean for the underlying Java Bean property of this BeanPropertyAccessor to another Java Bean.

Parameters:
beanSource -
beanDestination -
Returns:
true, if no error occurs

determinePropertyType

public Class<?> determinePropertyType()
Determines the Class type for the property.

Returns:

getPropertyValue

public Object getPropertyValue(B bean)
Returns the property value for the underlying Java Bean property from the given Java Bean object.

Parameters:
bean -
Returns:
value or null if no value could be resolved

setPropertyValue

public boolean setPropertyValue(B bean,
                                Object value)
Sets the property value for the underlying Java Bean property for the given Java Bean object.

Parameters:
bean -
value -
Returns:
true if no error occurs

hasGetterOrSetter

public boolean hasGetterOrSetter()
Returns true, if the underlying Field has at least a getter or a setter method or both available.

Returns:

hasGetterAndSetter

public boolean hasGetterAndSetter()
Returns true, if the underlying Field has a getter and a setter method.

Returns:

hasGetter

public boolean hasGetter()
Returns true, if the method has no parameters but a return type.

Returns:

hasSetter

public boolean hasSetter()
Is true, if a method has only one parameter and begins with "set". A return type is optional.

Returns:

merge

public static <B> BeanPropertyAccessor<B> merge(BeanPropertyAccessor<B> beanPropertyAccessorA,
                                                BeanPropertyAccessor<B> beanPropertyAccessorB)
Merges two BeanPropertyAccessor instances into one if the underlying Class and property are equal.

Type Parameters:
B -
Parameters:
beanPropertyAccessorA -
beanPropertyAccessorB -
Returns:

getMethod

protected Method getMethod()

getBeanClass

public Class<?> getBeanClass()

getPropertyName

public String getPropertyName()
Returns:

getField

public Field getField()

getMethodGetter

public Method getMethodGetter()

getMethodSetter

public Method getMethodSetter()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.