Class SimpleBeanUtil


  • public abstract class SimpleBeanUtil
    extends java.lang.Object
    A simple bean util class that allows us to call setters that have a primitive param.
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleBeanUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean callSetter​(java.lang.Object obj, java.lang.String methodName, java.lang.String value)
      Invoke the setter method on the object.
      static java.util.Map<java.lang.String,​java.lang.reflect.Method> gettersAsMap​(java.lang.Class c)
      Return all the vanilla getters as a map keyed by the method name (uppercase).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SimpleBeanUtil

        public SimpleBeanUtil()
    • Method Detail

      • callSetter

        public static boolean callSetter​(java.lang.Object obj,
                                         java.lang.String methodName,
                                         java.lang.String value)
        Invoke the setter method on the object.

        Uses the first match, so overloaded methods may cause unexpected behaviour. Assumes that the String value can be converted into its corresponding primitive value (long/double/boolean/string/float/int). If it can't a runtime exception is probably going to be thrown.

        Parameters:
        obj - the object.
        methodName - the method name (e.g. setClientID, case insensitive match).
        value - the value; which will be converted into the appropriate primitive.
        Returns:
        true if the setter was successfully called; false otherwise.
      • gettersAsMap

        public static java.util.Map<java.lang.String,​java.lang.reflect.Method> gettersAsMap​(java.lang.Class c)
        Return all the vanilla getters as a map keyed by the method name (uppercase).
        Parameters:
        c - the class
        Returns:
        a Map keyed by string.