Class TypeErasure

java.lang.Object
etithespirit.orimod.util.TypeErasure

public final class TypeErasure extends Object
  • Constructor Details

    • TypeErasure

      public TypeErasure()
  • Method Details

    • eraseAndTreatAsGeneric

      public static <T> T eraseAndTreatAsGeneric(Object in)
      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

      public static <T> T[] translateArray(Object[] in, Class<T> tType)
      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.