Package org.jclouds.reflect
Class Reflection2
java.lang.Object
org.jclouds.reflect.Reflection2
Utilities that allow access to
Invokable
s with owner types
.- Since:
- 1.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> com.google.common.reflect.Invokable
<T, T> constructor
(Class<T> ownerType, Class<?>... parameterTypes) returns anInvokable
object that reflects a constructor present in theTypeToken
type.static <T> Collection
<com.google.common.reflect.Invokable<T, T>> constructors
(com.google.common.reflect.TypeToken<T> ownerType) return all constructors or static factory methods present in the class asInvokable
s.static List
<com.google.common.reflect.Parameter> getInvokableParameters
(com.google.common.reflect.Invokable<?, ?> invokable) Returns theParameter
s associated with the givenInvokable
.static <T,
R> com.google.common.reflect.Invokable <T, R> returns anInvokable
object that links themethod
to its owner.static <T,
R> com.google.common.reflect.Invokable <T, R> returns anInvokable
object that reflects a method present in theTypeToken
type.static <T> Collection
<com.google.common.reflect.Invokable<T, Object>> return all methods present in the class asInvokable
s.toClasses
(com.google.common.collect.ImmutableList<com.google.common.reflect.Parameter> params) static <T> com.google.common.reflect.TypeToken
<T> gets aTypeToken
for the given class.static <T> com.google.common.reflect.TypeToken
<T> gets aTypeToken
for the given type.
-
Constructor Details
-
Reflection2
public Reflection2()
-
-
Method Details
-
typeToken
gets aTypeToken
for the given type. -
typeToken
gets aTypeToken
for the given class. -
constructor
public static <T> com.google.common.reflect.Invokable<T,T> constructor(Class<T> ownerType, Class<?>... parameterTypes) returns anInvokable
object that reflects a constructor present in theTypeToken
type.- Parameters:
ownerType
- corresponds toInvokable.getOwnerType()
parameterTypes
- corresponds toConstructor.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 or static factory methods present in the class asInvokable
s.- Parameters:
ownerType
- corresponds toInvokable.getOwnerType()
-
method
public static <T,R> com.google.common.reflect.Invokable<T,R> method(com.google.common.reflect.TypeToken<T> ownerType, Method method) returns anInvokable
object that links themethod
to its owner.- Parameters:
ownerType
- corresponds toInvokable.getOwnerType()
method
- present inownerType
-
method
public static <T,R> com.google.common.reflect.Invokable<T,R> method(Class<T> ownerType, String name, Class<?>... parameterTypes) returns anInvokable
object that reflects a method present in theTypeToken
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 (seeClass.getDeclaredMethod(java.lang.String, java.lang.Class<?>...)
).- Parameters:
ownerType
- corresponds toInvokable.getOwnerType()
name
- name of the method to be returnedparameterTypes
- corresponds toMethod.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 asInvokable
s.- Parameters:
ownerType
- corresponds toInvokable.getOwnerType()
-
toClasses
-
getInvokableParameters
public static List<com.google.common.reflect.Parameter> getInvokableParameters(com.google.common.reflect.Invokable<?, ?> invokable) Returns theParameter
s associated with the givenInvokable
. This function is backed by a cache.- Parameters:
invokable
- TheInvokable
we want to get Parameters from
-