Package org.apache.hadoop.util
Class GenericsUtil
java.lang.Object
org.apache.hadoop.util.GenericsUtil
Contains utility methods for dealing with Java Generics.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Class<T>getClass(T t) Returns the Class object (of typeClass<T>) of the argument of typeT.static booleanisLog4jLogger(Class<?> clazz) Determine whether the log ofclazzis Log4j implementation.static booleanisLog4jLogger(String logger) Determine whether the log of the given logger is of Log4J implementation.static <T> T[]Converts the givenList<T>to a an array ofT[].static <T> T[]Converts the givenList<T>to a an array ofT[].
-
Constructor Details
-
GenericsUtil
public GenericsUtil()
-
-
Method Details
-
getClass
Returns the Class object (of typeClass<T>) of the argument of typeT.- Type Parameters:
T- The type of the argument- Parameters:
t- the object to get it class- Returns:
Class<T>
-
toArray
Converts the givenList<T>to a an array ofT[].- Type Parameters:
T- Generics Type T.- Parameters:
c- the Class object of the items in the listlist- the list to convert- Returns:
- T Array.
-
toArray
Converts the givenList<T>to a an array ofT[].- Type Parameters:
T- Generics Type T.- Parameters:
list- the list to convert- Returns:
- T Array.
- Throws:
ArrayIndexOutOfBoundsException- if the list is empty. UsetoArray(Class, List)if the list may be empty.
-
isLog4jLogger
Determine whether the log ofclazzis Log4j implementation.- Parameters:
clazz- a class to be determined- Returns:
- true if the log of
clazzis Log4j implementation.
-
isLog4jLogger
Determine whether the log of the given logger is of Log4J implementation.- Parameters:
logger- the logger name, usually class name as string.- Returns:
- true if the logger uses Log4J implementation.
-