Class InitialisationUtil
- java.lang.Object
-
- com.digitalpebble.stormcrawler.util.InitialisationUtil
-
public final class InitialisationUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> @NotNull Class<? extends T>
getClassFor(@NotNull String qualifiedClassName, @NotNull Class<? extends T> superClass, @NotNull Class<?>... furtherSuperClasses)
Retrieves a class-instance forqualifiedClassName
extendingT
.static <T> T
initializeFromClass(@NotNull Class<?> clazz, @NotNull Class<? extends T> superClass, @NotNull Class<?>... furtherSuperClasses)
Initializes a class fromclazz
as typesuperClass
.static <T> T
initializeFromClass(@NotNull Class<? extends T> clazz)
Initializes a class fromclazz
of typeT
.static <T> T
initializeFromQualifiedName(@NotNull String qualifiedClassName, @NotNull Class<? extends T> superClass, @NotNull Class<?>... furtherSuperClasses)
Initializes a class fromqualifiedClassName
as typesuperClass
.static <T> Class<? extends T>
requireSuperClass(@NotNull Class<?> clazz, @NotNull Class<? extends T> superClass, @NotNull Class<?>... furtherSuperClasses)
Asserts the following:
-
-
-
Method Detail
-
initializeFromQualifiedName
@NotNull @Contract(pure=true) public static <T> T initializeFromQualifiedName(@NotNull @NotNull String qualifiedClassName, @NotNull @NotNull Class<? extends T> superClass, @NotNull @NotNull Class<?>... furtherSuperClasses)
Initializes a class fromqualifiedClassName
as typesuperClass
. Further constrains for implemented classes and interfaces are possible viafurtherSuperClasses
.Requirements:
qualifiedClassName
:- Has an accessible empty constructor.
- Points to a class extending/implementing
superClass
. - Points to a class extending/implementing all
furtherSuperClasses
. - Points to a class that is not primitive, abstract or an interface.
- Points to an existing class.
- Is not blank.
superClass
:- Does not point to a primitive.
- Points to a class extending/implemented by the class of
qualifiedClassName
.
furtherSuperClasses
- Points to classes extending/implemented by the class of
qualifiedClassName
.
- Type Parameters:
T
- the type of the returned class.- Parameters:
qualifiedClassName
- the qualified name for the class to be initialized.superClass
- defines the type to be instantiatedfurtherSuperClasses
- further checks for specific interfaces etc.- Returns:
- an instance of
qualifiedClassName
of typesuperClass
extending/implementing allfurtherSuperClasses
. - Throws:
RuntimeException
- if thesuperClass
is not assignable to the class ofclazz
RuntimeException
- if any of thefurtherSuperClasses
is not assignable to the class ofclazz
RuntimeException
- if thesuperClass
is a primitiveRuntimeException
- if theclazz
is not pointing to a class.RuntimeException
- if theclazz
is blank.RuntimeException
- if either the underlying constructor is inaccessbible, no empty constructor found or the underlying class is somehow abstract.RuntimeException
- if the underlying constructor threw an exception.RuntimeException
- if theclazz
points to a interface, abstract class or primitive.
-
getClassFor
@NotNull @Contract(pure=true) public static <T> @NotNull Class<? extends T> getClassFor(@NotNull @NotNull String qualifiedClassName, @NotNull @NotNull Class<? extends T> superClass, @NotNull @NotNull Class<?>... furtherSuperClasses)
Retrieves a class-instance forqualifiedClassName
extendingT
.T
is supplied by contraining the type ofqualifiedClassName
tosuperClass
. Further constrains for implemented classes and interfaces are possible viafurtherSuperClasses
.Requirements:
clazz
:- Points to a class extending/implementing
superClass
. - Points to a class extending/implementing all
furtherSuperClasses
. - Points to a class that is not primitive, abstract or an interface.
- Points to an existing class.
- Is not blank.
superClass
:- Does not point to a primitive.
- Points to a class extending/implemented by the class of
clazz
.
furtherSuperClasses
- Points to classes extending/implemented by the class of
clazz
.
- Type Parameters:
T
- the type extended by the returned class.- Parameters:
qualifiedClassName
- the qualified name for the class to be retrieved.superClass
- defines the type to be instantiatedfurtherSuperClasses
- further checks for specific interfaces etc.- Returns:
- an instance of
clazz
of typesuperClass
extending/implementing allfurtherSuperClasses
. - Throws:
RuntimeException
- if thesuperClass
is not assignable to the class ofclazz
RuntimeException
- if any of thefurtherSuperClasses
is not assignable to the class ofclazz
RuntimeException
- if thesuperClass
is a primitiveRuntimeException
- if theclazz
is not pointing to a class.RuntimeException
- if theclazz
is blank.
- Points to a class extending/implementing
-
initializeFromClass
@NotNull @Contract(pure=true) public static <T> T initializeFromClass(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull Class<? extends T> superClass, @NotNull @NotNull Class<?>... furtherSuperClasses)
Initializes a class fromclazz
as typesuperClass
. Further constrains for implemented classes and interfaces are possible viafurtherSuperClasses
.Requirements:
clazz
:- Has an accessible empty constructor.
- Points to a class extending/implementing
superClass
. - Points to a class extending/implementing all
furtherSuperClasses
. - Points to a class that is not primitive, abstract or an interface.
- Points to an existing class.
- Is not blank.
superClass
:- Does not point to a primitive.
- Points to a class extending/implemented by the class of
clazz
.
furtherSuperClasses
- Points to classes extending/implemented by the class of
clazz
.
- Type Parameters:
T
- the type of the returned class.- Parameters:
clazz
- the class to be initialized.superClass
- defines the type to be instantiatedfurtherSuperClasses
- further checks for specific interfaces etc.- Returns:
- an instance of
clazz
of typesuperClass
extending/implementing allfurtherSuperClasses
. - Throws:
RuntimeException
- if either the underlying constructor is inaccessbible, no empty constructor found or the underlying class is somehow abstract.RuntimeException
- if the underlying constructor threw an exception.RuntimeException
- if theclazz
points to a interface, abstract class or primitive.RuntimeException
- if thesuperClass
is not assignable to the class ofclazz
RuntimeException
- if any of thefurtherSuperClasses
is not assignable to the class ofclazz
RuntimeException
- if thesuperClass
is a primitive
-
initializeFromClass
@NotNull @Contract(pure=true) public static <T> T initializeFromClass(@NotNull @NotNull Class<? extends T> clazz)
Initializes a class fromclazz
of typeT
.Requirements:
clazz
:- Points to a class that is not primitive, abstract or an interface.
- Type Parameters:
T
- the type of the returned class.- Parameters:
clazz
- the class to be initialized.- Returns:
- an instance of
clazz
. - Throws:
RuntimeException
- if either the underlying constructor is inaccessbible, no empty constructor found or the underlying class is somehow abstract.RuntimeException
- if the underlying constructor threw an exception.RuntimeException
- if theclazz
points to a interface, abstract class or primitive.
-
requireSuperClass
@Contract(pure=true) public static <T> Class<? extends T> requireSuperClass(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull Class<? extends T> superClass, @NotNull @NotNull Class<?>... furtherSuperClasses)
Asserts the following:clazz
:- Points to a class extending/implementing
superClass
. - Points to a class extending/implementing all
furtherSuperClasses
. - Points to a class that is not primitive, abstract or an interface.
superClass
:- Does not point to a primitive.
- Points to a class extending/implemented by the class of
clazz
.
furtherSuperClasses
- Points to classes extending/implemented by the class of
clazz
.
- Returns:
- Either fails or returns
clazz
cast to Class<? extends T> - Throws:
RuntimeException
- if theclazz
points to a interface, abstract class or primitive.RuntimeException
- if thesuperClass
is not assignable to the class ofclazz
RuntimeException
- if any of thefurtherSuperClasses
is not assignable to the class ofclazz
RuntimeException
- if thesuperClass
is a primitive
- Points to a class extending/implementing
-
-