Class CType<T>

  • All Implemented Interfaces:
    CTypeI<T>, ToString
    Direct Known Subclasses:
    CType.WType

    public abstract class CType<T>
    extends java.lang.Object
    implements CTypeI<T>
    • Method Detail

      • mutable

        public boolean mutable()
        Description copied from interface: CTypeI
        Checks if the type is mutable (can be modified after creation).
        Specified by:
        mutable in interface CTypeI<T>
        Returns:
        true if the type is mutable, false otherwise
      • getFieldAccessor

        public <FT> CTypeI.FieldAccessor<FT> getFieldAccessor​(java.lang.String field)
        Description copied from interface: CTypeI
        Gets a field accessor for the specified field name.
        Specified by:
        getFieldAccessor in interface CTypeI<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: CTypeI
        Gets a field accessor for the specified field.
        Specified by:
        getFieldAccessor in interface CTypeI<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: CTypeI
        Adds annotations to this type and returns a new type instance with the annotations.
        Specified by:
        addAnnotations in interface CTypeI<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: CTypeI
        Gets the simple name of the raw type with type parameters.
        Specified by:
        getRawSimpleNameWithParameters in interface CTypeI<T>
        Returns:
        the simple name with type parameters
      • getRawSimpleNameWithParameters

        public void getRawSimpleNameWithParameters​(AString sb2)
        Description copied from interface: CTypeI
        Appends the simple name of the raw type with type parameters to the specified string builder.
        Specified by:
        getRawSimpleNameWithParameters in interface CTypeI<T>
        Parameters:
        sb2 - the string builder to append to
      • getCanonicalNameWithParameters

        public java.lang.CharSequence getCanonicalNameWithParameters()
        Description copied from interface: CTypeI
        Gets the canonical name of the type with type parameters.
        Specified by:
        getCanonicalNameWithParameters in interface CTypeI<T>
        Returns:
        the canonical name with type parameters
      • getCanonicalNameWithParameters

        public void getCanonicalNameWithParameters​(AString sb)
        Description copied from interface: CTypeI
        Appends the canonical name of the type with type parameters to the specified string builder.
        Specified by:
        getCanonicalNameWithParameters in interface CTypeI<T>
        Parameters:
        sb - the string builder to append to
      • getRawSimpleName

        public java.lang.String getRawSimpleName()
        Description copied from interface: CTypeI
        Gets the simple name of the raw type.
        Specified by:
        getRawSimpleName in interface CTypeI<T>
        Returns:
        the simple name of the raw type
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • declareCode

        public java.lang.String declareCode()
        Description copied from interface: CTypeI
        Gets the declaration code for this type, including annotations and type parameters.
        Specified by:
        declareCode in interface CTypeI<T>
        Returns:
        the declaration code
      • toId

        public java.lang.String toId()
        Description copied from interface: CTypeI
        Gets a unique identifier for this type.
        Specified by:
        toId in interface CTypeI<T>
        Returns:
        the unique identifier
      • getRaw2

        public java.lang.Class<?> getRaw2()
        Description copied from interface: CTypeI
        Gets the raw class representing this type (alternative to getRaw).
        Specified by:
        getRaw2 in interface CTypeI<T>
        Returns:
        the raw class
      • instanceOf

        public boolean instanceOf​(CTypeI<?> t)
        Description copied from interface: CTypeI
        Checks if this type is an instance of the specified type.
        Specified by:
        instanceOf in interface CTypeI<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: CTypeI
        Checks if this type is an instance of the specified annotated type.
        Specified by:
        instanceOf in interface CTypeI<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: CTypeI
        Converts this type to an AnnotatedType object.
        Specified by:
        toAnnotatedType in interface CTypeI<T>
        Returns:
        the AnnotatedType representation
      • getComponent

        public CTypeI<java.lang.Object> getComponent()
        Description copied from interface: CTypeI
        Gets the component type for array types.
        Specified by:
        getComponent in interface CTypeI<T>
        Returns:
        the component type, or null if not an array
      • getComponent

        public CTypeI<java.lang.Object> getComponent​(int i)
        Description copied from interface: CTypeI
        Gets the component type at the specified index.
        Specified by:
        getComponent in interface CTypeI<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: CTypeI
        Gets the component type for the specified base class and index.
        Specified by:
        getComponent in interface CTypeI<T>
        Parameters:
        base - the base class
        i - 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: CTypeI
        Checks if this type is annotated with the specified annotation.
        Specified by:
        isAnnotated in interface CTypeI<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: CTypeI
        Gets the specified annotation if present on this type.
        Specified by:
        getAnnotation in interface CTypeI<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: CTypeI
        Checks if this type represents an array.
        Specified by:
        isArray in interface CTypeI<T>
        Returns:
        true if this is an array type, false otherwise
      • isNumber

        public boolean isNumber()
        Description copied from interface: CTypeI
        Checks if this type represents a number (primitive or boxed).
        Specified by:
        isNumber in interface CTypeI<T>
        Returns:
        true if this is a number type, false otherwise
      • isEnum

        public boolean isEnum()
        Description copied from interface: CTypeI
        Checks if this type represents an enum.
        Specified by:
        isEnum in interface CTypeI<T>
        Returns:
        true if this is an enum type, false otherwise
      • isInterface

        public boolean isInterface()
        Description copied from interface: CTypeI
        Checks if this type represents an interface.
        Specified by:
        isInterface in interface CTypeI<T>
        Returns:
        true if this is an interface, false otherwise
      • getGenericVariables

        public java.lang.reflect.TypeVariable<?>[] getGenericVariables()
        Description copied from interface: CTypeI
        Gets the type variables for generic types.
        Specified by:
        getGenericVariables in interface CTypeI<T>
        Returns:
        the type variables
      • getMethods

        public Flow<java.lang.reflect.Method> getMethods()
        Description copied from interface: CTypeI
        Gets all declared methods of this type.
        Specified by:
        getMethods in interface CTypeI<T>
        Returns:
        a flow of declared methods
      • getAllFields

        public Flow<java.lang.reflect.Field> getAllFields()
        Description copied from interface: CTypeI
        Gets all fields of this type, including inherited ones.
        Specified by:
        getAllFields in interface CTypeI<T>
        Returns:
        a flow of all fields
      • getAllMethods

        public Flow<java.lang.reflect.Method> getAllMethods()
        Description copied from interface: CTypeI
        Gets all methods of this type, including inherited ones.
        Specified by:
        getAllMethods in interface CTypeI<T>
        Returns:
        a flow of all methods
      • getFields

        public Flow<java.lang.reflect.Field> getFields()
        Description copied from interface: CTypeI
        Gets all declared fields of this type.
        Specified by:
        getFields in interface CTypeI<T>
        Returns:
        a flow of declared fields
      • getAnnotations

        public java.lang.annotation.Annotation[] getAnnotations()
        Description copied from interface: CTypeI
        Gets all annotations on this type.
        Specified by:
        getAnnotations in interface CTypeI<T>
        Returns:
        an array of annotations
      • isBoxedOrRawPrimitive

        public boolean isBoxedOrRawPrimitive()
        Description copied from interface: CTypeI
        Checks if this type represents a boxed primitive or raw primitive.
        Specified by:
        isBoxedOrRawPrimitive in interface CTypeI<T>
        Returns:
        true if this is a boxed or raw primitive, false otherwise
      • getChildrenClasses

        public CTypeI<? extends T>[] getChildrenClasses()
        Description copied from interface: CTypeI
        Gets the permitted subclasses for this sealed type.
        Specified by:
        getChildrenClasses in interface CTypeI<T>
        Returns:
        an array of permitted subclasses
      • getAllDependencies

        public void getAllDependencies​(java.util.Set<CTypeI<?>> res,
                                       boolean withTransient)
        Description copied from interface: CTypeI
        Collects all dependencies of this type.
        Specified by:
        getAllDependencies in interface CTypeI<T>
        Parameters:
        res - the set to store dependencies in
        withTransient - whether to include transient dependencies
      • getAllChildrenClasses

        public Flow<CTypeI<? extends T>> getAllChildrenClasses()
        Description copied from interface: CTypeI
        Gets all children classes of this type, including nested subclasses.
        Specified by:
        getAllChildrenClasses in interface CTypeI<T>
        Returns:
        a flow of all children classes
      • isAbstract

        public boolean isAbstract()
        Description copied from interface: CTypeI
        Checks if this type is abstract.
        Specified by:
        isAbstract in interface CTypeI<T>
        Returns:
        true if this type is abstract, false otherwise
      • getInterfaces

        public Flow<CTypeI<?>> getInterfaces()
        Description copied from interface: CTypeI
        Gets all interfaces implemented by this type.
        Specified by:
        getInterfaces in interface CTypeI<T>
        Returns:
        a flow of interface types
      • makeAuto

        public T makeAuto​(java.lang.Object... args)
        Description copied from interface: CTypeI
        Creates a new instance of this type with the specified arguments.
        Specified by:
        makeAuto in interface CTypeI<T>
        Parameters:
        args - the constructor arguments
        Returns:
        a new instance
      • getFieldVarHandle

        public java.lang.invoke.VarHandle getFieldVarHandle​(java.lang.reflect.Field field)
        Description copied from interface: CTypeI
        Gets a VarHandle for the specified field.
        Specified by:
        getFieldVarHandle in interface CTypeI<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: CTypeI
        Gets a VarHandle for the field with the specified name.
        Specified by:
        getFieldVarHandle in interface CTypeI<T>
        Parameters:
        name - the field name
        Returns:
        a VarHandle for the field
      • maker

        public ASupplier<?> maker()
        Description copied from interface: CTypeI
        Gets a supplier that can create instances of this type.
        Specified by:
        maker in interface CTypeI<T>
        Returns:
        a supplier for creating instances
      • getConstructor

        public java.lang.reflect.Constructor<?> getConstructor​(java.lang.Class<?>... args)
        Description copied from interface: CTypeI
        Gets the constructor with the specified parameter types.
        Specified by:
        getConstructor in interface CTypeI<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: CTypeI
        Gets a MethodHandle for the constructor with the specified parameter types.
        Specified by:
        maker in interface CTypeI<T>
        Parameters:
        args - the parameter types
        Returns:
        a MethodHandle for the constructor
      • getEnumValues

        public java.lang.Enum<?>[] getEnumValues()
        Description copied from interface: CTypeI
        Gets the enum values if this type represents an enum.
        Specified by:
        getEnumValues in interface CTypeI<T>
        Returns:
        an array of enum values, or null if not an enum
      • isAetherClass

        public boolean isAetherClass()
        Description copied from interface: CTypeI
        Checks if this type is part of the Aether framework.
        Specified by:
        isAetherClass in interface CTypeI<T>
        Returns:
        true if this is an Aether class, false otherwise
      • getCanonicalName

        public java.lang.String getCanonicalName()
        Description copied from interface: CTypeI
        Gets the canonical name of this type.
        Specified by:
        getCanonicalName in interface CTypeI<T>
        Returns:
        the canonical name
      • isParametrizedClass

        public boolean isParametrizedClass()
        Description copied from interface: CTypeI
        Checks if this type is a parameterized class.
        Specified by:
        isParametrizedClass in interface CTypeI<T>
        Returns:
        true if this is a parameterized class, false otherwise
      • isVariable

        public boolean isVariable()
        Description copied from interface: CTypeI
        Checks if this type is a type variable.
        Specified by:
        isVariable in interface CTypeI<T>
        Returns:
        true if this is a type variable, false otherwise
      • isParameterizedType

        public boolean isParameterizedType()
        Description copied from interface: CTypeI
        Checks if this type is a parameterized type.
        Specified by:
        isParameterizedType in interface CTypeI<T>
        Returns:
        true if this is a parameterized type, false otherwise
      • getPackage

        public java.lang.String getPackage()
        Description copied from interface: CTypeI
        Gets the package name for this type.
        Specified by:
        getPackage in interface CTypeI<T>
        Returns:
        the package name
      • isInstance

        public boolean isInstance​(java.lang.Object o)
        Description copied from interface: CTypeI
        Checks if the specified object is an instance of this type.
        Specified by:
        isInstance in interface CTypeI<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: CTypeI
        Compares two values of this type, potentially using custom comparison logic.
        Specified by:
        compareValues in interface CTypeI<T>
        Parameters:
        val1 - the first value
        val2 - the second value
        consumer - the comparison event consumer
        Returns:
        true if the values are equal, false otherwise
      • toArray

        public CTypeI<T[]> toArray()
        Description copied from interface: CTypeI
        Converts this type to an array type.
        Specified by:
        toArray in interface CTypeI<T>
        Returns:
        the array type
      • cast

        public <C> CTypeI<C> cast()
        Description copied from interface: CTypeI
        Casts this type to the specified type.
        Specified by:
        cast in interface CTypeI<T>
        Type Parameters:
        C - the target type
        Returns:
        the cast type
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Description copied from interface: CTypeI
        Gets the class loader associated with this type.
        Specified by:
        getClassLoader in interface CTypeI<T>
        Returns:
        the class loader
      • cast

        public T cast​(java.lang.Object o)
        Description copied from interface: CTypeI
        Casts the specified object to this type.
        Specified by:
        cast in interface CTypeI<T>
        Parameters:
        o - the object to cast
        Returns:
        the cast object