Class IntrospectionUtils

  • public final class IntrospectionUtils
    extends Object
    Utils for introspection and reflection
    • Constructor Detail

      • IntrospectionUtils

        public IntrospectionUtils()
    • Method Detail

      • setProperty

        public static boolean setProperty​(Object o,
                                          String name,
                                          String value)
        Find a method with the right name If found, call the method ( if param is int or boolean we'll convert value to the right type before) - that means you can have setDebug(1).
        o - The object to set a property on
        name - The property name
        value - The property value
        true if operation was successful
      • setProperty

        public static boolean setProperty​(Object o,
                                          String name,
                                          String value,
                                          boolean invokeSetProperty)
      • escape

        public static String escape​(String s)
        s - the input string
        escaped string, per Java rule
      • replaceProperties

        public static String replaceProperties​(String value,
                                               Hashtable<Object,​Object> staticProp,
                                               IntrospectionUtils.PropertySource[] dynamicProp,
                                               ClassLoader classLoader)
        Replaces ${NAME} in the value with the value of the property 'NAME'. Replaces ${NAME:DEFAULT} with the value of the property 'NAME:DEFAULT', if the property 'NAME:DEFAULT' is not set, the expression is replaced with the value of the property 'NAME', if the property 'NAME' is not set, the expression is replaced with 'DEFAULT'. If the property is not set and there is no default the value will be returned unmodified.
        value - The value
        staticProp - Replacement properties
        dynamicProp - Replacement properties
        classLoader - Class loader associated with the code requesting the property
        the replacement value
      • capitalize

        public static String capitalize​(String name)
        Reverse of Introspector.decapitalize.
        name - The name
        the capitalized string
      • clear

        public static void clear()
      • findMethods

        public static Method[] findMethods​(Class<?> c)
      • isInstance

        public static boolean isInstance​(Class<?> clazz,
                                         String type)
        Checks to see if the specified class is an instance of or assignable from the specified type. The class clazz, all its superclasses, interfaces and those superinterfaces are tested for a match against the type name type. This is similar to instanceof or Class.isAssignableFrom(java.lang.Class<?>) except that the target type will not be resolved into a Class object, which provides some security and memory benefits.
        clazz - The class to test for a match.
        type - The name of the type that clazz must be.
        true if the clazz tested is an instance of the specified type, false otherwise.