Class GenericClass<T>
java.lang.Object
dev.scsupercraft.mc.libraries.corelib.serialization.GenericClass<T>
- Type Parameters:
T- The raw class type being represented.
A reflective wrapper around generic types, used to resolve type parameters and annotations
for codec generation and serialization logic.
Supports nested generics, arrays, wildcards, and annotated types.
Do not touch unless you know what you are doing!
Supports nested generics, arrays, wildcards, and annotated types.
Do not touch unless you know what you are doing!
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal @Nullable AnnotatedTypeA nullableAnnotatedTypefor getting annotations if present.final booleanIs this an array type?The class that this generic class represents.final GenericClass<?> The enclosing generic class, used to resolve type variables recursively.final Map<TypeVariable<Class<T>>, GenericClass<?>> The type parameters for the class. -
Constructor Summary
ConstructorsConstructorDescriptionGenericClass(GenericClass<T> arrayType, @Nullable AnnotatedType annotations) Creates a new generic class as an array type.GenericClass(Class<T> tClass, @Nullable AnnotatedType annotations) Creates a new generic class representing the provided class.GenericClass(Class<T> tClass, @Nullable AnnotatedType annotations, @Nullable GenericClass<?> parent) Creates a new generic class representing the provided class.GenericClass(Class<T> tClass, @Nullable AnnotatedType annotations, @Nullable GenericClass<?> parent, AnnotatedType[] typeParameters) Creates a new generic class representing the provided class.GenericClass(Class<T> tClass, @Nullable AnnotatedType annotations, @Nullable GenericClass<?> parent, Type[] typeParameters) Creates a new generic class representing the provided class.GenericClass(Class<T> tClass, @Nullable AnnotatedType annotations, @Nullable GenericClass<?> parent, Function<GenericClass<T>, GenericClass<?>[]> typeParameterProvider) Creates a new generic class representing the provided class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic GenericClass<?> of(AnnotatedType annotatedType) Creates a generic class from anAnnotatedType.static GenericClass<?> of(AnnotatedType annotatedType, GenericClass<?> parentType) Creates a generic class from anAnnotatedType.static GenericClass<?> of(Type type, @Nullable AnnotatedType annotatedType) Creates a generic class for aTypeand a nullableAnnotatedTypestatic GenericClass<?> of(Type type, @Nullable AnnotatedType annotatedType, GenericClass<?> parentType) Creates a generic class for aTypeand a nullableAnnotatedTypetoString()Iterator<? extends GenericClass<?>> Creates anIteratorfor the type parameters, staying in the order that they were defined in.
-
Field Details
-
parent
The enclosing generic class, used to resolve type variables recursively. -
clazz
The class that this generic class represents. -
typeParameters
The type parameters for the class. -
array
public final boolean arrayIs this an array type? -
annotations
A nullableAnnotatedTypefor getting annotations if present.See
TagKeyCodecResolverfor an example of how it's used.
-
-
Constructor Details
-
GenericClass
Creates a new generic class as an array type.- Parameters:
arrayType- The type stored in the array.annotations- The annotations for this type.
-
GenericClass
Creates a new generic class representing the provided class.- Parameters:
tClass- The class this generic class represents.annotations- The annotations for this type.
-
GenericClass
public GenericClass(Class<T> tClass, @Nullable @Nullable AnnotatedType annotations, @Nullable @Nullable GenericClass<?> parent) Creates a new generic class representing the provided class.- Parameters:
tClass- The class this generic class represents.annotations- The annotations for this type.parent- The generic class that encloses this one.
-
GenericClass
public GenericClass(Class<T> tClass, @Nullable @Nullable AnnotatedType annotations, @Nullable @Nullable GenericClass<?> parent, Type[] typeParameters) Creates a new generic class representing the provided class.- Parameters:
tClass- The class this generic class represents.annotations- The annotations for this type.parent- The generic class that encloses this one.typeParameters- The type parameters used.
-
GenericClass
public GenericClass(Class<T> tClass, @Nullable @Nullable AnnotatedType annotations, @Nullable @Nullable GenericClass<?> parent, AnnotatedType[] typeParameters) Creates a new generic class representing the provided class.- Parameters:
tClass- The class this generic class represents.annotations- The annotations for this type.parent- The generic class that encloses this one.typeParameters- The type parameters used.
-
GenericClass
public GenericClass(Class<T> tClass, @Nullable @Nullable AnnotatedType annotations, @Nullable @Nullable GenericClass<?> parent, Function<GenericClass<T>, GenericClass<?>[]> typeParameterProvider) Creates a new generic class representing the provided class.Implementation note: Use this constructor when type parameters depend on runtime resolution or recursive context.
- Parameters:
tClass- The class this generic class represents.annotations- The annotations for this type.parent- The generic class that encloses this one.typeParameterProvider- A function that gets given this generic class during creation and returns the type parameters used. This is here in case you need to use more advanced generics.
-
-
Method Details
-
of
Creates a generic class from anAnnotatedType.- Parameters:
annotatedType- The annotated type.- Returns:
- The generic class representing the annotated type.
-
of
Creates a generic class from anAnnotatedType.- Parameters:
annotatedType- The annotated type.parentType- The generic class that encloses this one.- Returns:
- The generic class representing the annotated type.
-
of
Creates a generic class for aTypeand a nullableAnnotatedType- Parameters:
type- The type.annotatedType- The annotated type.- Returns:
- The generic class representing both the type and annotated type.
-
of
public static GenericClass<?> of(Type type, @Nullable @Nullable AnnotatedType annotatedType, GenericClass<?> parentType) Creates a generic class for aTypeand a nullableAnnotatedType- Parameters:
type- The type.annotatedType- The annotated type.parentType- The generic class that encloses this one.- Returns:
- The generic class representing both the type and annotated type.
-
typeParameterIterator
Creates anIteratorfor the type parameters, staying in the order that they were defined in.- Returns:
- The iterator.
-
toString
-
equals
-