org.mule.devkit.dynamic.api.helper
Class Reflections

java.lang.Object
  extended by org.mule.devkit.dynamic.api.helper.Reflections

public final class Reflections
extends Object

Helper methods for reflection.


Method Summary
static Class<?> asType(Class<?> type)
           
static Object get(Object object, String propertyName)
          Get value of property for specified object.
static String getterMethodName(String propertyName)
           
static
<T> T
invoke(Object object, String method)
           
static
<T> T
invoke(Object object, String method, Object argument)
           
static
<T> T
invoke(Object object, String method, Object argument, Class<?> argumentType)
           
static void set(Object object, Map<String,Object> parameters)
          Sets parameters for specified object.
static void set(Object object, String propertyName, Object value)
          Sets property to value for specified object.
static Field setAccessible(Object object, String propertyName)
           
static String setterMethodName(String propertyName)
           
static Class<?> toPrimitive(Class<?> type)
           
static Class<?> toType(Class<?> type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setAccessible

public static Field setAccessible(Object object,
                                  String propertyName)

getterMethodName

public static String getterMethodName(String propertyName)
Parameters:
propertyName -
Returns:
default getter name for specified property

get

public static Object get(Object object,
                         String propertyName)
Get value of property for specified object.

Parameters:
object -
propertyName -

setterMethodName

public static String setterMethodName(String propertyName)
Parameters:
propertyName -
Returns:
default setter name for specified property

set

public static void set(Object object,
                       String propertyName,
                       Object value)
Sets property to value for specified object.

Parameters:
object -
propertyName -
value -

set

public static void set(Object object,
                       Map<String,Object> parameters)
Sets parameters for specified object.

Parameters:
object -
parameters -

toPrimitive

public static Class<?> toPrimitive(Class<?> type)
Parameters:
type -
Returns:
primitive equivalent type for specified Class
Throws:
IllegalArgumentException - ig specified Class is not Class.isPrimitive()

toType

public static Class<?> toType(Class<?> type)
Parameters:
type -
Returns:
bridge equivalent type for specified Class
Throws:
IllegalArgumentException - ig specified Class is not Class.isPrimitive()

asType

public static Class<?> asType(Class<?> type)
Parameters:
type -
Returns:
type representation of provided Class. Namely convert primitive to their type counterpart.
See Also:
Class.isPrimitive(), toType(java.lang.Class)

invoke

public static <T> T invoke(Object object,
                           String method,
                           Object argument)
Type Parameters:
T -
Parameters:
object -
method -
argument -
Returns:
result of dynamic invocation of `method` on `object` with `argument`.
See Also:
for inferred type from arguments

invoke

public static <T> T invoke(Object object,
                           String method,
                           Object argument,
                           Class<?> argumentType)
Type Parameters:
T -
Parameters:
object -
method -
argument -
argumentType -
Returns:
result of dynamic invocation of `method` on `object` with `argument`.

invoke

public static <T> T invoke(Object object,
                           String method)
Type Parameters:
T -
Parameters:
object -
method -
Returns:
result of dynamic invocation of `method` on `object` with no argument.


Copyright © 2010–2015 MuleSoft, Inc.. All rights reserved.