ch.elca.el4j.util.codingsupport
Class BeanPropertyUtils

java.lang.Object
  extended by ch.elca.el4j.util.codingsupport.BeanPropertyUtils

public final class BeanPropertyUtils
extends Object

Utility class to get/set properties generically.

Author:
David Bernhard (DBD)
File-location:
BeanPropertyUtils
Last check-in date:
2009-08-04 13:59:45 +0200 (Di, 04. Aug 2009) by swismer for revision 3873

Method Summary
static Object getProperty(Object entity, String propertyName)
          Generically get a property.
static Object getPropertySimplified(Object entity, String propertyName)
          Generically get a property, casting arrays to collections.
static Method getReadMethod(Class<?> entityClass, String propertyName)
          Get the read method of a property.
static Method getWriteMethod(Class<?> entityClass, String propertyName)
          Get the write method of a property.
static void setProperty(Object entity, String propertyName, Object value)
          Generically set a property.
static void setPropertySimplified(Object entity, String propertyName, Object value)
          Generically set a property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProperty

public static Object getProperty(Object entity,
                                 String propertyName)
Generically get a property.

Parameters:
entity - The entity to get a property on.
propertyName - The property name to get.
Returns:
The property value as returned from reading the property.

getPropertySimplified

public static Object getPropertySimplified(Object entity,
                                           String propertyName)
Generically get a property, casting arrays to collections.

Parameters:
entity - The entity to get a property on.
propertyName - The property name to get.
Returns:
The property value. If it was an array, it is returned as a collection.

setProperty

public static void setProperty(Object entity,
                               String propertyName,
                               Object value)
Generically set a property.

Parameters:
entity - The entity to set the property on.
propertyName - The property name.
value - The value to set.

setPropertySimplified

public static void setPropertySimplified(Object entity,
                                         String propertyName,
                                         Object value)
Generically set a property. If the setter requires an array, a collection may be passed too in which case it is put into an array.

Parameters:
entity - The entity to set the property on.
propertyName - The property name.
value - The value to set.

getReadMethod

public static Method getReadMethod(Class<?> entityClass,
                                   String propertyName)
Get the read method of a property.

Parameters:
entityClass - the class of the entity
propertyName - the property name
Returns:
the read method to access the property

getWriteMethod

public static Method getWriteMethod(Class<?> entityClass,
                                    String propertyName)
Get the write method of a property.

Parameters:
entityClass - the class of the entity
propertyName - the property name
Returns:
the write method to access the property


Copyright © 2005-2011 ELCA. All Rights Reserved.