Modifier and Type | Field and Description |
---|---|
static String |
JAVA7_CLASS_NAME_SUFFIX
The suffix used for Java 7 classes, the string "7".
|
Constructor and Description |
---|
Java7Util() |
Modifier and Type | Method and Description |
---|---|
static <T> Class<? extends T> |
loadClass(Class<T> baseClass)
Returns the Java 7 version of the given class if it exists and can be
loaded, and the given
baseClass otherwise. |
static <T> T |
newInstance(Class<T> baseClass,
T defaultInstance)
Returns a new instance of the Java 7 version of the given class if it
exists and can be instantiated.
|
public static final String JAVA7_CLASS_NAME_SUFFIX
public Java7Util()
public static <T> T newInstance(Class<T> baseClass, T defaultInstance)
defaultInstance
is returned.
The Java 7 version of the class must be a subtype of baseClass
and its fully qualified name must be identical to that of
baseClass
with a suffix "7". For instance, if the Java 6 base
class is called "org.unix4j.MyClass", the Java 7 version must be called
"org.unix4j.MyClass7". Furthermore, the class must have a default
constructor with no arguments.
If the Java 7 version of the class is not found (usually because unix4j
was compiled with a Java 6 compiler) or if the Java 7 class cannot be
instantiated (usually because unix4j is run in a Java 6 JVM), the given
defaultInstance
is returned.
T
- the generic return typebaseClass
- the base class and superclass of the Java 7 classdefaultInstance
otherwisepublic static <T> Class<? extends T> loadClass(Class<T> baseClass)
baseClass
otherwise.
The Java 7 version of the class must be a subtype of baseClass
and its fully qualified name must be identical to that of
baseClass
with a suffix "7". For instance, if the Java 6 base
class is called "org.unix4j.MyClass", the Java 7 version must be called
"org.unix4j.MyClass7".
If the Java 7 version of the class is not found (usually because unix4j
was compiled with a Java 6 compiler), the given defaultInstance
is returned. If the class is found but it is not a subtype of the given
baseClass
, an exception is thrown.
T
- the generic type of the base classbaseClass
- the base class and superclass of the Java 7 classbaseClass
otherwiseNullPointerException
- if baseClass
is nullIllegalArgumentException
- if the Java 7 class is found but it is not a subclass of
baseClass
Copyright © 2016. All rights reserved.