@Beta public class Reflection2 extends Object
Invokable
s with owner types
.Constructor and Description |
---|
Reflection2() |
Modifier and Type | Method and Description |
---|---|
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 or static factory methods present in the class as
Invokable s. |
static List<com.google.common.reflect.Parameter> |
getInvokableParameters(com.google.common.reflect.Invokable<?,?> invokable)
Returns the
Parameter s associated with the given Invokable . |
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
Invokable s. |
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. |
public static <T> com.google.common.reflect.TypeToken<T> typeToken(Type in)
TypeToken
for the given type.public static <T> com.google.common.reflect.TypeToken<T> typeToken(Class<T> in)
TypeToken
for the given class.public static <T> com.google.common.reflect.Invokable<T,T> constructor(Class<T> ownerType, Class<?>... parameterTypes)
Invokable
object that reflects a constructor present in the TypeToken
type.ownerType
- corresponds to Invokable.getOwnerType()
parameterTypes
- corresponds to Constructor.getParameterTypes()
IllegalArgumentException
- if the constructor doesn't exist or a security exception occurredpublic static <T> Collection<com.google.common.reflect.Invokable<T,T>> constructors(com.google.common.reflect.TypeToken<T> ownerType)
Invokable
s.ownerType
- corresponds to Invokable.getOwnerType()
public static <T,R> com.google.common.reflect.Invokable<T,R> method(com.google.common.reflect.TypeToken<T> ownerType, Method method)
Invokable
object that links the method
to its owner.ownerType
- corresponds to Invokable.getOwnerType()
method
- present in ownerType
public static <T,R> com.google.common.reflect.Invokable<T,R> method(Class<T> ownerType, String name, Class<?>... parameterTypes)
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<?>...)
).ownerType
- corresponds to Invokable.getOwnerType()
name
- name of the method to be returnedparameterTypes
- corresponds to Method.getParameterTypes()
IllegalArgumentException
- if the method doesn't exist or a security exception occurredpublic static <T> Collection<com.google.common.reflect.Invokable<T,Object>> methods(Class<T> ownerType)
Invokable
s.ownerType
- corresponds to Invokable.getOwnerType()
protected static List<Class<?>> toClasses(com.google.common.collect.ImmutableList<com.google.common.reflect.Parameter> params)
public static List<com.google.common.reflect.Parameter> getInvokableParameters(com.google.common.reflect.Invokable<?,?> invokable)
Parameter
s associated with the given Invokable
. This function is backed by a cache.invokable
- The Invokable
we want to get Parameters fromCopyright © 2009-2016 The Apache Software Foundation. All Rights Reserved.