Class BeanUtil


  • public final class BeanUtil
    extends java.lang.Object
    Some simple bean introspection methods. To avoid a dependency on the awt java.beans.introspector which is a desktop level class.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private BeanUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String capitalize​(java.lang.String fieldName)
      capitalize according to java beans specification
      static java.lang.String decapitalize​(java.lang.String name)
      decapitalize according to java beans specification.
      static java.lang.String getterName​(java.lang.String fieldName, java.lang.Class<?> type)
      Calculate the name of a getter based on the name of it's field and the type
      static java.lang.String setterName​(java.lang.String fieldName)
      Calculate the name of a setter based on the name of it's field
      • Methods inherited from class java.lang.Object

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

      • BeanUtil

        private BeanUtil()
    • Method Detail

      • getterName

        public static java.lang.String getterName​(java.lang.String fieldName,
                                                  java.lang.Class<?> type)
        Calculate the name of a getter based on the name of it's field and the type
        Parameters:
        fieldName - of the field
        type - of the field
        Returns:
        "get" or "is" method name for the field
      • setterName

        public static java.lang.String setterName​(java.lang.String fieldName)
        Calculate the name of a setter based on the name of it's field
        Parameters:
        fieldName - of the field
        Returns:
        "set" method name for the field
      • capitalize

        public static java.lang.String capitalize​(java.lang.String fieldName)
        capitalize according to java beans specification
      • decapitalize

        public static java.lang.String decapitalize​(java.lang.String name)
        decapitalize according to java beans specification. That is start the given field with a lower case, but only if the 2nd char is not also an uppercase character. eg; "Enabled" will become "enabled", but "URL" will remain "URL".