Package gw.lang.reflect
Class TypeBase
- java.lang.Object
-
- gw.lang.reflect.AbstractType
-
- gw.lang.reflect.TypeBase
-
- All Implemented Interfaces:
IType,Serializable
public abstract class TypeBase extends AbstractType implements IType
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected IJavaClassInfo_arrayComponentClass-
Fields inherited from interface gw.lang.reflect.IType
EMPTY_ARRAY, EMPTY_TYPE_ARRAY, EMPTY_TYPE_LIST
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTypeBase()protectedTypeBase(IJavaClassInfo arrayComponentClass)protectedTypeBase(Class<?> arrayComponentClass)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static Set<IType>getAllClassesInClassHierarchyAsIntrinsicTypes(IType type)Set<? extends IType>getAllTypesInHierarchy()Returns a Set of all IIntrinsicTypes that this class is assignable from, including this class.ObjectgetArrayComponent(Object array, int iIndex)Returns the value of the indexed component in the specified array object.protected IJavaClassInfogetArrayComponentClass()intgetArrayLength(Object array)Returns the length of the specified array object.ITypegetArrayType()Make an array type from this type.protected Set<IType>getArrayVersionsOfEachType(Set<? extends IType> componentTypes)ITypegetComponentType()If this is an array type, a type representing the component type of the array.Set<IType>getCompoundTypeComponents()StringgetDisplayName()The display name of this intrinsic type.ITypegetEnclosingType()Returns the type immediately enclosing this type.ITypegetGenericType()If this is a parameterized type, returns the generic type this type parameterizes.IGenericTypeVariable[]getGenericTypeVariables()Returns an array of GenericTypeVariables declared with this Generic Type.intgetModifiers()Returns the modifiers for this type, encoded in an integer.ITypegetParameterizedType(IType... ofType)Assuming this intrinsic type is a Generic type, return the parameterized type associated with the given list of type parameters.IType[]getTypeParameters()If this is a parameterized type, returns the specific types used to create this type, null otherwies.booleanisAbstract()booleanisArray()True if this is an array.booleanisAssignableFrom(IType type)Determines if the type represented by this intrinsic type is either the same as, or is a super-type of the type represented by the specified type parameter.booleanisCompoundType()booleanisDiscarded()True if this type has been replaced with a newer version of the same name in the type system.booleanisEnum()Returns true if this type is an enumeration.booleanisFinal()True if this type cannot be extended.booleanisGenericType()Returns true if this ia a Generic Type.booleanisInterface()Returns true if this type is an interface.booleanisMutable()Are intances of this type mutable? Note sometimes it's difficult to determine.booleanisParameterizedType()Returns true if this ia a Parameterized Type.booleanisPrimitive()True if this type represents a primitive type e.g., Java int, char, etc.booleanisValid()Defines this type if it is not yet fully defined.protected Set<? extends IType>loadAllTypesInHierarchy()IJavaTypeloadJavaType(String fullyQualifiedName)ObjectmakeArrayInstance(int iLength)Construct an array instance of specified length.protected ITypemakeArrayType()ObjectreadResolve()IType requires this method be implemented to ensure IType instances can be centrally defined and cached.voidsetArrayComponent(Object array, int iIndex, Object value)Sets the value of the indexed component in the specified array object.voidsetDiscarded(boolean bDiscarded)StringtoString()voidunloadTypeInfo()Unload or nullify any references to this IType's ITypeInfo.-
Methods inherited from class gw.lang.reflect.AbstractType
getLiteralMetaType, getMetaType, getTheRef
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gw.lang.reflect.IType
compile, getFunctionalInterface, getInterfaces, getLiteralMetaType, getMetaType, getName, getNamespace, getRelativeName, getSourceFiles, getSupertype, getTypeInfo, getTypeLoader, isCompilable, isDynamic
-
-
-
-
Field Detail
-
_arrayComponentClass
protected final transient IJavaClassInfo _arrayComponentClass
-
-
Constructor Detail
-
TypeBase
protected TypeBase(IJavaClassInfo arrayComponentClass)
-
TypeBase
protected TypeBase(Class<?> arrayComponentClass)
-
TypeBase
protected TypeBase()
-
-
Method Detail
-
makeArrayType
protected IType makeArrayType()
-
getEnclosingType
public IType getEnclosingType()
Description copied from interface:ITypeReturns the type immediately enclosing this type. If this type is not enclosed, returns null.- Specified by:
getEnclosingTypein interfaceIType
-
getGenericType
public IType getGenericType()
Description copied from interface:ITypeIf this is a parameterized type, returns the generic type this type parameterizes. Otherwise, returns null.- Specified by:
getGenericTypein interfaceIType
-
isFinal
public boolean isFinal()
Description copied from interface:ITypeTrue if this type cannot be extended.
-
isInterface
public boolean isInterface()
Description copied from interface:ITypeReturns true if this type is an interface.- Specified by:
isInterfacein interfaceIType
-
isEnum
public boolean isEnum()
Description copied from interface:ITypeReturns true if this type is an enumeration.
-
isParameterizedType
public boolean isParameterizedType()
Description copied from interface:ITypeReturns true if this ia a Parameterized Type. Note a Parameterzied Type is not the same as a Generic Type. The difference is that a Parameterized Type is a concrete version of a Generic Type. For instance, the class ArrayListis a Generic Type, while the class ArrayList is a Parameterized Type of the the Generic Type ArrayList . - Specified by:
isParameterizedTypein interfaceIType
-
isGenericType
public boolean isGenericType()
Description copied from interface:ITypeReturns true if this ia a Generic Type.- Specified by:
isGenericTypein interfaceIType- See Also:
IType.isParameterizedType()
-
getGenericTypeVariables
public IGenericTypeVariable[] getGenericTypeVariables()
Description copied from interface:ITypeReturns an array of GenericTypeVariables declared with this Generic Type. Otherwise, returns null if this is not a Generic Type.- Specified by:
getGenericTypeVariablesin interfaceIType
-
getParameterizedType
public IType getParameterizedType(IType... ofType)
Description copied from interface:ITypeAssuming this intrinsic type is a Generic type, return the parameterized type associated with the given list of type parameters. If the type has not been created yet, creates the parameterized type. Successive calls to this method having identical parameter types must return the identical parameterized type.- Specified by:
getParameterizedTypein interfaceIType- Parameters:
ofType- The type parameters.- Returns:
- The concrete type associated with the type parameters.
-
getTypeParameters
public IType[] getTypeParameters()
Description copied from interface:ITypeIf this is a parameterized type, returns the specific types used to create this type, null otherwies.- Specified by:
getTypeParametersin interfaceIType
-
isArray
public boolean isArray()
Description copied from interface:ITypeTrue if this is an array.
-
isPrimitive
public boolean isPrimitive()
Description copied from interface:ITypeTrue if this type represents a primitive type e.g., Java int, char, etc.- Specified by:
isPrimitivein interfaceIType
-
getArrayComponent
public Object getArrayComponent(Object array, int iIndex) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Description copied from interface:ITypeReturns the value of the indexed component in the specified array object.- Specified by:
getArrayComponentin interfaceIType- Parameters:
array- An array instance of this intrinsic type.iIndex- The index of the component to get.- Returns:
- The value of the indexed component in the specified array.
- Throws:
IllegalArgumentException- If the specified object is not an array.ArrayIndexOutOfBoundsException- If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
-
setArrayComponent
public void setArrayComponent(Object array, int iIndex, Object value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
Description copied from interface:ITypeSets the value of the indexed component in the specified array object.- Specified by:
setArrayComponentin interfaceIType- Parameters:
array- An array instance of this intrinsic type.iIndex- The index of the component to set.value- The new value of the indexed component.- Throws:
IllegalArgumentException- If the specified object is not an array.ArrayIndexOutOfBoundsException- If the specified index argument is negative, or if it is greater than or equal to the length of the specified array
-
getArrayLength
public int getArrayLength(Object array) throws IllegalArgumentException
Description copied from interface:ITypeReturns the length of the specified array object.- Specified by:
getArrayLengthin interfaceIType- Parameters:
array- An array instance of this intrinsic type.- Returns:
- The length of the array.
- Throws:
IllegalArgumentException- If the object argument is not an array.
-
getComponentType
public IType getComponentType()
Description copied from interface:ITypeIf this is an array type, a type representing the component type of the array. Otherwise null.- Specified by:
getComponentTypein interfaceIType
-
isMutable
public boolean isMutable()
Description copied from interface:ITypeAre intances of this type mutable? Note sometimes it's difficult to determine. For instance, java classes don't contain any information about mutability. In which case we always assume mutable, even when the underlying type may in fact be immutable. E.g., even though java.lang.String is not mutable, its corresponding JavaIntrinsicType will say it is.
-
readResolve
public Object readResolve() throws ObjectStreamException
Description copied from interface:ITypeIType requires this method be implemented to ensure IType instances can be centrally defined and cached.- Specified by:
readResolvein interfaceIType- Throws:
ObjectStreamException
-
isValid
public boolean isValid()
Description copied from interface:ITypeDefines this type if it is not yet fully defined. For instance, if this type has source code associated with it, it must fully compile the source for it to be fully defined.
-
getModifiers
public int getModifiers()
Description copied from interface:ITypeReturns the modifiers for this type, encoded in an integer. The modifiers consist of the constants forpublic,protected,private,final,static,abstractthey should be decoded using the methods of classModifier.- Specified by:
getModifiersin interfaceIType- See Also:
Modifier
-
isAbstract
public boolean isAbstract()
- Specified by:
isAbstractin interfaceIType
-
getDisplayName
public String getDisplayName()
Description copied from interface:ITypeThe display name of this intrinsic type. Often this is simply the same asIType.getName(), but in some cases a type may want to modify it's name for presentation to the user.- Specified by:
getDisplayNamein interfaceIType
-
getAllTypesInHierarchy
public Set<? extends IType> getAllTypesInHierarchy()
Description copied from interface:ITypeReturns a Set of all IIntrinsicTypes that this class is assignable from, including this class. This includes implemented interfaces and superclasses, recursively up the hieararchy. For array types, this will be a Set of all types that its component type is assignable from.- Specified by:
getAllTypesInHierarchyin interfaceIType
-
getAllClassesInClassHierarchyAsIntrinsicTypes
protected static Set<IType> getAllClassesInClassHierarchyAsIntrinsicTypes(IType type)
-
getArrayVersionsOfEachType
protected Set<IType> getArrayVersionsOfEachType(Set<? extends IType> componentTypes)
-
isAssignableFrom
public boolean isAssignableFrom(IType type)
Description copied from interface:ITypeDetermines if the type represented by this intrinsic type is either the same as, or is a super-type of the type represented by the specified type parameter.- Specified by:
isAssignableFromin interfaceIType
-
getArrayType
public IType getArrayType()
Description copied from interface:ITypeMake an array type from this type. E.g., String -> String[]- Specified by:
getArrayTypein interfaceIType
-
makeArrayInstance
public Object makeArrayInstance(int iLength)
Description copied from interface:ITypeConstruct an array instance of specified length.- Specified by:
makeArrayInstancein interfaceIType
-
getArrayComponentClass
protected IJavaClassInfo getArrayComponentClass()
-
unloadTypeInfo
public void unloadTypeInfo()
Description copied from interface:ITypeUnload or nullify any references to this IType's ITypeInfo.- Specified by:
unloadTypeInfoin interfaceIType
-
isDiscarded
public boolean isDiscarded()
Description copied from interface:ITypeTrue if this type has been replaced with a newer version of the same name in the type system.- Specified by:
isDiscardedin interfaceIType
-
setDiscarded
public void setDiscarded(boolean bDiscarded)
- Specified by:
setDiscardedin interfaceIType
-
isCompoundType
public boolean isCompoundType()
- Specified by:
isCompoundTypein interfaceIType
-
getCompoundTypeComponents
public Set<IType> getCompoundTypeComponents()
- Specified by:
getCompoundTypeComponentsin interfaceIType
-
-