org.jclouds.reflect
Class Reflection2

java.lang.Object
  extended by org.jclouds.reflect.Reflection2

@Beta
public class Reflection2
extends Object

Utilities that allow access to Invokables with owner types.

Since:
1.6

Constructor Summary
Reflection2()
           
 
Method Summary
static
<T> com.google.common.reflect.Invokable<T,T>
constructor(Class<T> ownerType, Class<?>... parameterTypes)
          returns an Invokable object that reflects a constructor present in the TypeToken type.
static
<T> Collection<com.google.common.reflect.Invokable<T,T>>
constructors(com.google.common.reflect.TypeToken<T> ownerType)
          return all constructors present in the class as Invokables.
static
<T,R> com.google.common.reflect.Invokable<T,R>
method(Class<T> ownerType, String name, Class<?>... parameterTypes)
          returns an Invokable object that reflects a method present in the TypeToken type.
static
<T,R> com.google.common.reflect.Invokable<T,R>
method(com.google.common.reflect.TypeToken<T> ownerType, Method method)
          returns an Invokable object that links the method to its owner.
static
<T> Collection<com.google.common.reflect.Invokable<T,Object>>
methods(Class<T> ownerType)
          return all methods present in the class as Invokables.
protected static List<Class<?>> toClasses(com.google.common.collect.ImmutableList<com.google.common.reflect.Parameter> params)
           
static
<T> com.google.common.reflect.TypeToken<T>
typeToken(Class<T> in)
          gets a TypeToken for the given class.
static
<T> com.google.common.reflect.TypeToken<T>
typeToken(Type in)
          gets a TypeToken for the given type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Reflection2

public Reflection2()
Method Detail

typeToken

public static <T> com.google.common.reflect.TypeToken<T> typeToken(Type in)
gets a TypeToken for the given type.


typeToken

public static <T> com.google.common.reflect.TypeToken<T> typeToken(Class<T> in)
gets a TypeToken for the given class.


constructor

public static <T> com.google.common.reflect.Invokable<T,T> constructor(Class<T> ownerType,
                                                                       Class<?>... parameterTypes)
returns an Invokable object that reflects a constructor present in the TypeToken type.

Parameters:
ownerType - corresponds to Invokable.getOwnerType()
parameterTypes - corresponds to Constructor.getParameterTypes()
Throws:
IllegalArgumentException - if the constructor doesn't exist or a security exception occurred

constructors

public static <T> Collection<com.google.common.reflect.Invokable<T,T>> constructors(com.google.common.reflect.TypeToken<T> ownerType)
return all constructors present in the class as Invokables.

Parameters:
ownerType - corresponds to Invokable.getOwnerType()

method

public static <T,R> com.google.common.reflect.Invokable<T,R> method(com.google.common.reflect.TypeToken<T> ownerType,
                                                                    Method method)
returns an Invokable object that links the method to its owner.

Parameters:
ownerType - corresponds to Invokable.getOwnerType()
method - present in ownerType

method

public static <T,R> com.google.common.reflect.Invokable<T,R> method(Class<T> ownerType,
                                                                    String name,
                                                                    Class<?>... parameterTypes)
returns an Invokable object that reflects a method present in the TypeToken type. If there are multiple methods of the same name and parameter list, returns the method in the nearest ancestor with the most specific return type (see Class.getDeclaredMethod(java.lang.String, java.lang.Class...)).

Parameters:
ownerType - corresponds to Invokable.getOwnerType()
name - name of the method to be returned
parameterTypes - corresponds to Method.getParameterTypes()
Throws:
IllegalArgumentException - if the method doesn't exist or a security exception occurred

methods

public static <T> Collection<com.google.common.reflect.Invokable<T,Object>> methods(Class<T> ownerType)
return all methods present in the class as Invokables.

Parameters:
ownerType - corresponds to Invokable.getOwnerType()

toClasses

protected static List<Class<?>> toClasses(com.google.common.collect.ImmutableList<com.google.common.reflect.Parameter> params)


Copyright © 2009-2013 jclouds. All Rights Reserved.