public class ReflectionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getPackagePath(Class klass)
Get package path to the class given.
|
static String |
getPackagePath(Object object)
Get package path to the object given.
|
static <T> Class<?>[] |
getTypeArguments(Class<T> baseClass,
Class<? extends T> childClass)
Get the actual type arguments a child class has used to extend a
generic base class.
|
static <T> T |
newInstance(Class<T> theClass)
Instantiate a class, wrap exceptions
|
static <T> T |
newInstance(Class<T> theClass,
ImmutableClassesGiraphConfiguration configuration)
Instantiate classes that are ImmutableClassesGiraphConfigurable
|
static <T> T |
newInstance(Class<T> theClass,
ImmutableClassesGiraphConfiguration configuration,
org.apache.hadoop.mapreduce.Mapper.Context context)
Instantiate classes that are ImmutableClassesGiraphConfigurable,
and optionally set context on them if they are ContextSettable
|
static void |
verifyConcrete(Class<?> concrete,
String typeDesc)
Verify that given type is a concrete type that can be instantiated.
|
static void |
verifyTypes(Class<?> concreteChild,
Class<?> parent,
String typeDesc,
Class<?> mainClass)
Verify that found type matches the expected type.
|
public static String getPackagePath(Object object)
object
- the Object to checkpublic static String getPackagePath(Class klass)
klass
- Class to checkpublic static <T> Class<?>[] getTypeArguments(Class<T> baseClass, Class<? extends T> childClass)
T
- Type to evaluate.baseClass
- the base classchildClass
- the child classpublic static <T> T newInstance(Class<T> theClass)
T
- Type to instantiatetheClass
- Class to instantiatepublic static <T> T newInstance(Class<T> theClass, ImmutableClassesGiraphConfiguration configuration)
T
- Type to instantiatetheClass
- Class to instantiateconfiguration
- Giraph configuration, may be nullpublic static <T> T newInstance(Class<T> theClass, ImmutableClassesGiraphConfiguration configuration, org.apache.hadoop.mapreduce.Mapper.Context context)
T
- Type to instantiatetheClass
- Class to instantiateconfiguration
- Giraph configuration, may be nullcontext
- Mapper contextpublic static void verifyTypes(Class<?> concreteChild, Class<?> parent, String typeDesc, Class<?> mainClass)
IllegalStateException
will be thrown.concreteChild
- Concrete child typeparent
- Parent typetypeDesc
- String description of the type (for exception description)mainClass
- Class in which the actual type was found (for exception
description)Copyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.