Package etithespirit.orimod.util
Class TypeErasure
java.lang.Object
etithespirit.orimod.util.TypeErasure
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
A method that (hilariously) abuses Java's type erasure to allow crudely casting into any generic type to make the compiler happy and the engineers sad.static <T> T[]
translateArray
(Object[] in, Class<T> tType) Translates an array of Object[] into an array of T[]
-
Constructor Details
-
TypeErasure
public TypeErasure()
-
-
Method Details
-
eraseAndTreatAsGeneric
A method that (hilariously) abuses Java's type erasure to allow crudely casting into any generic type to make the compiler happy and the engineers sad.- Type Parameters:
T
- The type of the generic.- Parameters:
in
- The object to treat as a generic type.- Returns:
- The exact same object, except the Java compiler thinks its an instance of T now lol.
-
translateArray
Translates an array of Object[] into an array of T[]- Type Parameters:
T
- The type of the array.- Parameters:
in
- The arbitrary array.tType
- The class to use when creating the array.- Returns:
- An array with a more specific type.
-