no.priv.garshol.duke.utils
Class ObjectUtils

java.lang.Object
  extended by no.priv.garshol.duke.utils.ObjectUtils

public class ObjectUtils
extends Object


Constructor Summary
ObjectUtils()
           
 
Method Summary
static Object getEnumConstantByName(Class klass, String name)
          Returns the enum constant from the given enum class representing the constant with the given identifier/name.
static Object instantiate(String klassname)
           
static void setBeanProperty(Object object, String prop, String value, Map<String,Object> objects)
          Calls the named bean setter property on the object, converting the given value to the correct type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectUtils

public ObjectUtils()
Method Detail

getEnumConstantByName

public static Object getEnumConstantByName(Class klass,
                                           String name)
Returns the enum constant from the given enum class representing the constant with the given identifier/name.


setBeanProperty

public static void setBeanProperty(Object object,
                                   String prop,
                                   String value,
                                   Map<String,Object> objects)
Calls the named bean setter property on the object, converting the given value to the correct type. Note that parameter 'prop' is converted to a method name according to Lisp convention: (foo-bar), and not the usual Java dromedaryCase (fooBar). So "foo-bar" will become "setFooBar".

The value conversion is mostly straightforward, except that if the type of the method's first parameter is not a java.lang.Something, then the method will assume that the value is the name of an object in the 'objects' map, and pass that.


instantiate

public static Object instantiate(String klassname)


Copyright © 2013. All Rights Reserved.