Package io.aether.utils
Class CType<T>
- java.lang.Object
-
- io.aether.utils.CType<T>
-
- Direct Known Subclasses:
CType.WType
public abstract class CType<T> extends java.lang.Object implements CTypeI<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCType.WType<T>-
Nested classes/interfaces inherited from interface io.aether.utils.CTypeI
CTypeI.CompareEvent, CTypeI.FieldAccessor<T2>
-
-
Field Summary
-
Fields inherited from interface io.aether.utils.CTypeI
BOOLEAN, BOOLEAN_ARR, BOOLEAN_BOX, BYTE, BYTE_ARR, BYTE_BOX, CHAR, CHAR_BOX, CLASS_NAME, DOUBLE, DOUBLE_ARR, DOUBLE_BOX, FLOAT, FLOAT_ARR, FLOAT_BOX, INT, INT_ARR, INT_BOX, LONG, LONG_ARR, LONG_BOX, SHORT, SHORT_ARR, SHORT_BOX, STRING, UBYTE, UINT, ULONG, UNSIGNED, USHORT
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CTypeI<T>addAnnotations(java.lang.annotation.Annotation... aa)Adds annotations to this type and returns a new type instance with the annotations.<C> CTypeI<C>cast()Casts this type to the specified type.Tcast(java.lang.Object o)Casts the specified object to this type.booleancompareValues(T val1, T val2, CTypeI.CompareEvent consumer)Compares two values of this type, potentially using custom comparison logic.java.lang.StringdeclareCode()Gets the declaration code for this type, including annotations and type parameters.booleanequals(java.lang.Object o)Flow<CTypeI<? extends T>>getAllChildrenClasses()Gets all children classes of this type, including nested subclasses.voidgetAllDependencies(java.util.Set<CTypeI<?>> res, boolean withTransient)Collects all dependencies of this type.Flow<java.lang.reflect.Field>getAllFields()Gets all fields of this type, including inherited ones.Flow<java.lang.reflect.Method>getAllMethods()Gets all methods of this type, including inherited ones.<A extends java.lang.annotation.Annotation>
AgetAnnotation(java.lang.Class<A> aClass)Gets the specified annotation if present on this type.java.lang.annotation.Annotation[]getAnnotations()Gets all annotations on this type.java.lang.StringgetCanonicalName()Gets the canonical name of this type.java.lang.CharSequencegetCanonicalNameWithParameters()Gets the canonical name of the type with type parameters.voidgetCanonicalNameWithParameters(AString sb)Appends the canonical name of the type with type parameters to the specified string builder.CTypeI<? extends T>[]getChildrenClasses()Gets the permitted subclasses for this sealed type.java.lang.ClassLoadergetClassLoader()Gets the class loader associated with this type.CTypeI<java.lang.Object>getComponent()Gets the component type for array types.CTypeI<java.lang.Object>getComponent(int i)Gets the component type at the specified index.CTypeI<java.lang.Object>getComponent(java.lang.Class<?> base, int i)Gets the component type for the specified base class and index.java.lang.reflect.Constructor<?>getConstructor(java.lang.Class<?>... args)Gets the constructor with the specified parameter types.java.lang.Enum<?>[]getEnumValues()Gets the enum values if this type represents an enum.<FT> CTypeI.FieldAccessor<FT>getFieldAccessor(java.lang.reflect.Field field)Gets a field accessor for the specified field.<FT> CTypeI.FieldAccessor<FT>getFieldAccessor(java.lang.String field)Gets a field accessor for the specified field name.Flow<java.lang.reflect.Field>getFields()Gets all declared fields of this type.java.lang.invoke.VarHandlegetFieldVarHandle(java.lang.reflect.Field field)Gets a VarHandle for the specified field.java.lang.invoke.VarHandlegetFieldVarHandle(java.lang.String name)Gets a VarHandle for the field with the specified name.java.lang.reflect.TypeVariable<?>[]getGenericVariables()Gets the type variables for generic types.Flow<CTypeI<?>>getInterfaces()Gets all interfaces implemented by this type.Flow<java.lang.reflect.Method>getMethods()Gets all declared methods of this type.java.lang.StringgetPackage()Gets the package name for this type.java.lang.Class<?>getRaw2()Gets the raw class representing this type (alternative to getRaw).java.lang.StringgetRawSimpleName()Gets the simple name of the raw type.java.lang.StringgetRawSimpleNameWithParameters()Gets the simple name of the raw type with type parameters.voidgetRawSimpleNameWithParameters(AString sb2)Appends the simple name of the raw type with type parameters to the specified string builder.inthashCode()booleaninstanceOf(CTypeI<?> t)Checks if this type is an instance of the specified type.booleaninstanceOf(java.lang.reflect.AnnotatedType t)Checks if this type is an instance of the specified annotated type.booleanisAbstract()Checks if this type is abstract.booleanisAetherClass()Checks if this type is part of the Aether framework.booleanisAnnotated(java.lang.Class<? extends java.lang.annotation.Annotation> aClass)Checks if this type is annotated with the specified annotation.booleanisArray()Checks if this type represents an array.booleanisBoxedOrRawPrimitive()Checks if this type represents a boxed primitive or raw primitive.booleanisEnum()Checks if this type represents an enum.booleanisInstance(java.lang.Object o)Checks if the specified object is an instance of this type.booleanisInterface()Checks if this type represents an interface.booleanisNumber()Checks if this type represents a number (primitive or boxed).booleanisParameterizedType()Checks if this type is a parameterized type.booleanisParametrizedClass()Checks if this type is a parameterized class.booleanisVariable()Checks if this type is a type variable.TmakeAuto(java.lang.Object... args)Creates a new instance of this type with the specified arguments.ASupplier<?>maker()Gets a supplier that can create instances of this type.java.lang.invoke.MethodHandlemaker(java.lang.Class<?>... args)Gets a MethodHandle for the constructor with the specified parameter types.booleanmutable()Checks if the type is mutable (can be modified after creation).@NotNull java.lang.reflect.AnnotatedTypetoAnnotatedType()Converts this type to an AnnotatedType object.CTypeI<T[]>toArray()Converts this type to an array type.java.lang.StringtoId()Gets a unique identifier for this type.java.lang.StringtoString()voidtoString(AString sb)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.aether.utils.CTypeI
getComponentByName, getParameters, getParent, getRaw, instanceOf, isBoxedPrimitive, isPrimitive, resolveExtend, resolveReturnType, resolveTypeArgs, resolveTypeField, toPrimitive, toType, tryToBox, unbox
-
-
-
-
Method Detail
-
mutable
public boolean mutable()
Description copied from interface:CTypeIChecks if the type is mutable (can be modified after creation).
-
getFieldAccessor
public <FT> CTypeI.FieldAccessor<FT> getFieldAccessor(java.lang.String field)
Description copied from interface:CTypeIGets a field accessor for the specified field name.- Specified by:
getFieldAccessorin interfaceCTypeI<T>- Type Parameters:
FT- the field type- Parameters:
field- the name of the field- Returns:
- a field accessor for the specified field
-
getFieldAccessor
public <FT> CTypeI.FieldAccessor<FT> getFieldAccessor(java.lang.reflect.Field field)
Description copied from interface:CTypeIGets a field accessor for the specified field.- Specified by:
getFieldAccessorin interfaceCTypeI<T>- Type Parameters:
FT- the field type- Parameters:
field- the field object- Returns:
- a field accessor for the specified field
-
addAnnotations
public CTypeI<T> addAnnotations(java.lang.annotation.Annotation... aa)
Description copied from interface:CTypeIAdds annotations to this type and returns a new type instance with the annotations.- Specified by:
addAnnotationsin interfaceCTypeI<T>- Parameters:
aa- the annotations to add- Returns:
- a new type instance with the added annotations
-
getRawSimpleNameWithParameters
public java.lang.String getRawSimpleNameWithParameters()
Description copied from interface:CTypeIGets the simple name of the raw type with type parameters.- Specified by:
getRawSimpleNameWithParametersin interfaceCTypeI<T>- Returns:
- the simple name with type parameters
-
getRawSimpleNameWithParameters
public void getRawSimpleNameWithParameters(AString sb2)
Description copied from interface:CTypeIAppends the simple name of the raw type with type parameters to the specified string builder.- Specified by:
getRawSimpleNameWithParametersin interfaceCTypeI<T>- Parameters:
sb2- the string builder to append to
-
getCanonicalNameWithParameters
public java.lang.CharSequence getCanonicalNameWithParameters()
Description copied from interface:CTypeIGets the canonical name of the type with type parameters.- Specified by:
getCanonicalNameWithParametersin interfaceCTypeI<T>- Returns:
- the canonical name with type parameters
-
getCanonicalNameWithParameters
public void getCanonicalNameWithParameters(AString sb)
Description copied from interface:CTypeIAppends the canonical name of the type with type parameters to the specified string builder.- Specified by:
getCanonicalNameWithParametersin interfaceCTypeI<T>- Parameters:
sb- the string builder to append to
-
getRawSimpleName
public java.lang.String getRawSimpleName()
Description copied from interface:CTypeIGets the simple name of the raw type.- Specified by:
getRawSimpleNamein interfaceCTypeI<T>- Returns:
- the simple name of the raw type
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
declareCode
public java.lang.String declareCode()
Description copied from interface:CTypeIGets the declaration code for this type, including annotations and type parameters.- Specified by:
declareCodein interfaceCTypeI<T>- Returns:
- the declaration code
-
toId
public java.lang.String toId()
Description copied from interface:CTypeIGets a unique identifier for this type.
-
getRaw2
public java.lang.Class<?> getRaw2()
Description copied from interface:CTypeIGets the raw class representing this type (alternative to getRaw).
-
instanceOf
public boolean instanceOf(CTypeI<?> t)
Description copied from interface:CTypeIChecks if this type is an instance of the specified type.- Specified by:
instanceOfin interfaceCTypeI<T>- Parameters:
t- the type to check against- Returns:
- true if this type is an instance of the specified type, false otherwise
-
instanceOf
public boolean instanceOf(java.lang.reflect.AnnotatedType t)
Description copied from interface:CTypeIChecks if this type is an instance of the specified annotated type.- Specified by:
instanceOfin interfaceCTypeI<T>- Parameters:
t- the annotated type to check against- Returns:
- true if this type is an instance of the specified type, false otherwise
-
toAnnotatedType
@NotNull public @NotNull java.lang.reflect.AnnotatedType toAnnotatedType()
Description copied from interface:CTypeIConverts this type to an AnnotatedType object.- Specified by:
toAnnotatedTypein interfaceCTypeI<T>- Returns:
- the AnnotatedType representation
-
getComponent
public CTypeI<java.lang.Object> getComponent()
Description copied from interface:CTypeIGets the component type for array types.- Specified by:
getComponentin interfaceCTypeI<T>- Returns:
- the component type, or null if not an array
-
getComponent
public CTypeI<java.lang.Object> getComponent(int i)
Description copied from interface:CTypeIGets the component type at the specified index.- Specified by:
getComponentin interfaceCTypeI<T>- Parameters:
i- the index of the component type- Returns:
- the component type, or null if not found
-
getComponent
public CTypeI<java.lang.Object> getComponent(java.lang.Class<?> base, int i)
Description copied from interface:CTypeIGets the component type for the specified base class and index.- Specified by:
getComponentin interfaceCTypeI<T>- Parameters:
base- the base classi- the index of the type parameter- Returns:
- the resolved component type
-
isAnnotated
public boolean isAnnotated(java.lang.Class<? extends java.lang.annotation.Annotation> aClass)
Description copied from interface:CTypeIChecks if this type is annotated with the specified annotation.- Specified by:
isAnnotatedin interfaceCTypeI<T>- Parameters:
aClass- the annotation class to check for- Returns:
- true if the annotation is present, false otherwise
-
getAnnotation
public <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<A> aClass)
Description copied from interface:CTypeIGets the specified annotation if present on this type.- Specified by:
getAnnotationin interfaceCTypeI<T>- Type Parameters:
A- the annotation type- Parameters:
aClass- the annotation class- Returns:
- the annotation, or null if not present
-
isArray
public boolean isArray()
Description copied from interface:CTypeIChecks if this type represents an array.
-
isNumber
public boolean isNumber()
Description copied from interface:CTypeIChecks if this type represents a number (primitive or boxed).
-
isEnum
public boolean isEnum()
Description copied from interface:CTypeIChecks if this type represents an enum.
-
isInterface
public boolean isInterface()
Description copied from interface:CTypeIChecks if this type represents an interface.- Specified by:
isInterfacein interfaceCTypeI<T>- Returns:
- true if this is an interface, false otherwise
-
getGenericVariables
public java.lang.reflect.TypeVariable<?>[] getGenericVariables()
Description copied from interface:CTypeIGets the type variables for generic types.- Specified by:
getGenericVariablesin interfaceCTypeI<T>- Returns:
- the type variables
-
getMethods
public Flow<java.lang.reflect.Method> getMethods()
Description copied from interface:CTypeIGets all declared methods of this type.- Specified by:
getMethodsin interfaceCTypeI<T>- Returns:
- a flow of declared methods
-
getAllFields
public Flow<java.lang.reflect.Field> getAllFields()
Description copied from interface:CTypeIGets all fields of this type, including inherited ones.- Specified by:
getAllFieldsin interfaceCTypeI<T>- Returns:
- a flow of all fields
-
getAllMethods
public Flow<java.lang.reflect.Method> getAllMethods()
Description copied from interface:CTypeIGets all methods of this type, including inherited ones.- Specified by:
getAllMethodsin interfaceCTypeI<T>- Returns:
- a flow of all methods
-
getFields
public Flow<java.lang.reflect.Field> getFields()
Description copied from interface:CTypeIGets all declared fields of this type.
-
getAnnotations
public java.lang.annotation.Annotation[] getAnnotations()
Description copied from interface:CTypeIGets all annotations on this type.- Specified by:
getAnnotationsin interfaceCTypeI<T>- Returns:
- an array of annotations
-
isBoxedOrRawPrimitive
public boolean isBoxedOrRawPrimitive()
Description copied from interface:CTypeIChecks if this type represents a boxed primitive or raw primitive.- Specified by:
isBoxedOrRawPrimitivein interfaceCTypeI<T>- Returns:
- true if this is a boxed or raw primitive, false otherwise
-
getChildrenClasses
public CTypeI<? extends T>[] getChildrenClasses()
Description copied from interface:CTypeIGets the permitted subclasses for this sealed type.- Specified by:
getChildrenClassesin interfaceCTypeI<T>- Returns:
- an array of permitted subclasses
-
getAllDependencies
public void getAllDependencies(java.util.Set<CTypeI<?>> res, boolean withTransient)
Description copied from interface:CTypeICollects all dependencies of this type.- Specified by:
getAllDependenciesin interfaceCTypeI<T>- Parameters:
res- the set to store dependencies inwithTransient- whether to include transient dependencies
-
getAllChildrenClasses
public Flow<CTypeI<? extends T>> getAllChildrenClasses()
Description copied from interface:CTypeIGets all children classes of this type, including nested subclasses.- Specified by:
getAllChildrenClassesin interfaceCTypeI<T>- Returns:
- a flow of all children classes
-
isAbstract
public boolean isAbstract()
Description copied from interface:CTypeIChecks if this type is abstract.- Specified by:
isAbstractin interfaceCTypeI<T>- Returns:
- true if this type is abstract, false otherwise
-
getInterfaces
public Flow<CTypeI<?>> getInterfaces()
Description copied from interface:CTypeIGets all interfaces implemented by this type.- Specified by:
getInterfacesin interfaceCTypeI<T>- Returns:
- a flow of interface types
-
makeAuto
public T makeAuto(java.lang.Object... args)
Description copied from interface:CTypeICreates a new instance of this type with the specified arguments.
-
getFieldVarHandle
public java.lang.invoke.VarHandle getFieldVarHandle(java.lang.reflect.Field field)
Description copied from interface:CTypeIGets a VarHandle for the specified field.- Specified by:
getFieldVarHandlein interfaceCTypeI<T>- Parameters:
field- the field- Returns:
- a VarHandle for the field
-
getFieldVarHandle
public java.lang.invoke.VarHandle getFieldVarHandle(java.lang.String name)
Description copied from interface:CTypeIGets a VarHandle for the field with the specified name.- Specified by:
getFieldVarHandlein interfaceCTypeI<T>- Parameters:
name- the field name- Returns:
- a VarHandle for the field
-
maker
public ASupplier<?> maker()
Description copied from interface:CTypeIGets a supplier that can create instances of this type.
-
getConstructor
public java.lang.reflect.Constructor<?> getConstructor(java.lang.Class<?>... args)
Description copied from interface:CTypeIGets the constructor with the specified parameter types.- Specified by:
getConstructorin interfaceCTypeI<T>- Parameters:
args- the parameter types- Returns:
- the matching constructor, or null if not found
-
maker
public java.lang.invoke.MethodHandle maker(java.lang.Class<?>... args)
Description copied from interface:CTypeIGets a MethodHandle for the constructor with the specified parameter types.
-
getEnumValues
public java.lang.Enum<?>[] getEnumValues()
Description copied from interface:CTypeIGets the enum values if this type represents an enum.- Specified by:
getEnumValuesin interfaceCTypeI<T>- Returns:
- an array of enum values, or null if not an enum
-
isAetherClass
public boolean isAetherClass()
Description copied from interface:CTypeIChecks if this type is part of the Aether framework.- Specified by:
isAetherClassin interfaceCTypeI<T>- Returns:
- true if this is an Aether class, false otherwise
-
getCanonicalName
public java.lang.String getCanonicalName()
Description copied from interface:CTypeIGets the canonical name of this type.- Specified by:
getCanonicalNamein interfaceCTypeI<T>- Returns:
- the canonical name
-
isParametrizedClass
public boolean isParametrizedClass()
Description copied from interface:CTypeIChecks if this type is a parameterized class.- Specified by:
isParametrizedClassin interfaceCTypeI<T>- Returns:
- true if this is a parameterized class, false otherwise
-
isVariable
public boolean isVariable()
Description copied from interface:CTypeIChecks if this type is a type variable.- Specified by:
isVariablein interfaceCTypeI<T>- Returns:
- true if this is a type variable, false otherwise
-
isParameterizedType
public boolean isParameterizedType()
Description copied from interface:CTypeIChecks if this type is a parameterized type.- Specified by:
isParameterizedTypein interfaceCTypeI<T>- Returns:
- true if this is a parameterized type, false otherwise
-
getPackage
public java.lang.String getPackage()
Description copied from interface:CTypeIGets the package name for this type.- Specified by:
getPackagein interfaceCTypeI<T>- Returns:
- the package name
-
isInstance
public boolean isInstance(java.lang.Object o)
Description copied from interface:CTypeIChecks if the specified object is an instance of this type.- Specified by:
isInstancein interfaceCTypeI<T>- Parameters:
o- the object to check- Returns:
- true if the object is an instance of this type, false otherwise
-
compareValues
public boolean compareValues(T val1, T val2, CTypeI.CompareEvent consumer)
Description copied from interface:CTypeICompares two values of this type, potentially using custom comparison logic.- Specified by:
compareValuesin interfaceCTypeI<T>- Parameters:
val1- the first valueval2- the second valueconsumer- the comparison event consumer- Returns:
- true if the values are equal, false otherwise
-
toArray
public CTypeI<T[]> toArray()
Description copied from interface:CTypeIConverts this type to an array type.
-
cast
public <C> CTypeI<C> cast()
Description copied from interface:CTypeICasts this type to the specified type.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:CTypeIGets the class loader associated with this type.- Specified by:
getClassLoaderin interfaceCTypeI<T>- Returns:
- the class loader
-
-