org.cojen.util
Class BeanPropertyAccessor<B>

java.lang.Object
  extended by org.cojen.util.BeanPropertyAccessor<B>

public abstract class BeanPropertyAccessor<B>
extends Object

Provides a simple and efficient means of reading and writing bean properties. BeanPropertyAccessor auto-generates code, eliminating the need to invoke methods via reflection. Bean access methods are bound-to directly, using a special hash/switch design pattern.

Author:
Brian S O'Neill
See Also:
BeanPropertyMapFactory

Nested Class Summary
static class BeanPropertyAccessor.PropertySet
           
 
Constructor Summary
protected BeanPropertyAccessor()
           
 
Method Summary
static
<B> BeanPropertyAccessor<B>
forClass(Class<B> clazz)
          Returns a new or cached BeanPropertyAccessor for the given class.
static
<B> BeanPropertyAccessor<B>
forClass(Class<B> clazz, BeanPropertyAccessor.PropertySet set)
           
abstract  Object getPropertyValue(B bean, String property)
           
abstract  boolean hasPropertyValue(B bean, Object value)
          Returns true if at least one property is set to the given value.
abstract  boolean hasReadableProperty(String property)
          Returns true if readable bean property exists.
abstract  boolean hasWritableProperty(String property)
          Returns true if writable bean property exists.
abstract  void setPropertyValue(B bean, String property, Object value)
           
abstract  Object tryGetPropertyValue(B bean, String property)
          Returns property value or null if it does not exist.
abstract  boolean trySetPropertyValue(B bean, String property, Object value)
          Tries to set property value, if it exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanPropertyAccessor

protected BeanPropertyAccessor()
Method Detail

forClass

public static <B> BeanPropertyAccessor<B> forClass(Class<B> clazz)
Returns a new or cached BeanPropertyAccessor for the given class.


forClass

public static <B> BeanPropertyAccessor<B> forClass(Class<B> clazz,
                                                   BeanPropertyAccessor.PropertySet set)

getPropertyValue

public abstract Object getPropertyValue(B bean,
                                        String property)
                                 throws NoSuchPropertyException
Throws:
NoSuchPropertyException

setPropertyValue

public abstract void setPropertyValue(B bean,
                                      String property,
                                      Object value)
                               throws NoSuchPropertyException
Throws:
NoSuchPropertyException

hasReadableProperty

public abstract boolean hasReadableProperty(String property)
Returns true if readable bean property exists.

Since:
2.1

hasWritableProperty

public abstract boolean hasWritableProperty(String property)
Returns true if writable bean property exists.

Since:
2.1

hasPropertyValue

public abstract boolean hasPropertyValue(B bean,
                                         Object value)
Returns true if at least one property is set to the given value.

Since:
2.1

tryGetPropertyValue

public abstract Object tryGetPropertyValue(B bean,
                                           String property)
Returns property value or null if it does not exist.

Since:
2.1

trySetPropertyValue

public abstract boolean trySetPropertyValue(B bean,
                                            String property,
                                            Object value)
Tries to set property value, if it exists.

Returns:
false if property doesn't exist
Since:
2.1


Copyright © 2004-2011 Brian S O'Neill. All Rights Reserved.