Class CtEnumImpl<T extends Enum<?>>
- java.lang.Object
-
- spoon.support.reflect.declaration.CtElementImpl
-
- spoon.support.reflect.declaration.CtNamedElementImpl
-
- spoon.support.reflect.declaration.CtTypeImpl<T>
-
- spoon.support.reflect.declaration.CtClassImpl<T>
-
- spoon.support.reflect.declaration.CtEnumImpl<T>
-
- All Implemented Interfaces:
Serializable
,Cloneable
,FactoryAccessor
,CtCodeElement
,CtStatement
,SourcePositionHolder
,CtClass<T>
,CtElement
,CtEnum<T>
,CtFormalTypeDeclarer
,CtModifiable
,CtNamedElement
,CtSealable
,CtShadowable
,CtType<T>
,CtTypeInformation
,CtTypeMember
,CtQueryable
,CtVisitable
public class CtEnumImpl<T extends Enum<?>> extends CtClassImpl<T> implements CtEnum<T>
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class spoon.support.reflect.declaration.CtElementImpl
ERROR_MESSAGE_TO_STRING, factory, LOGGER, parent
-
Fields inherited from interface spoon.reflect.declaration.CtType
INNERTTYPE_SEPARATOR, NAME_UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description CtEnumImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(CtVisitor visitor)
Accepts a visitor<C extends CtEnum<T>>
CaddEnumValue(CtEnumValue<?> enumValue)
Adds an enum value.CtEnum<T>
addPermittedType(CtTypeReference<?> type)
Adds a permitted type to this type.CtEnum<T>
clone()
Clone the element which calls this method in a new object.Set<CtMethod<?>>
getAllMethods()
Return all the methods that can be called on an instance of this type.CtEnumValue<?>
getEnumValue(String name)
Gets an enum value by its name.List<CtEnumValue<?>>
getEnumValues()
Gets all enum values of the enumeration.CtField<?>
getField(String name)
Gets a field from its name.List<CtField<?>>
getFields()
Returns the fields that are directly declared by this class or interface.List<CtTypeParameter>
getFormalCtTypeParameters()
Returns the formal type parameters of this generic element.<R> CtMethod<R>
getMethod(String name, CtTypeReference<?>... parameterTypes)
Gets a method from its name and parameter types.<R> CtMethod<R>
getMethod(CtTypeReference<R> returnType, String name, CtTypeReference<?>... parameterTypes)
Gets a method from its return type, name, and parameter types.Set<CtTypeReference<?>>
getPermittedTypes()
Returns the permitted types for this type.CtTypeReference<?>
getSuperclass()
Returns the class type directly extended by this class.boolean
isClass()
Returns true if this type is a class.boolean
isEnum()
Returns true if this type is an enum.boolean
isSubtypeOf(CtTypeReference<?> type)
Returns true if the referenced type is a sub-type of the given type.boolean
removeEnumValue(CtEnumValue<?> enumValue)
Removes en enum value.CtEnum<T>
removePermittedType(CtTypeReference<?> type)
Adds a permitted type to this type.<C extends CtEnum<T>>
CsetEnumValues(List<CtEnumValue<?>> enumValues)
Sets all enum values of the enum.<C extends CtFormalTypeDeclarer>
CsetFormalCtTypeParameters(List<CtTypeParameter> formalTypeParameters)
Sets the type parameters of this generic element.CtEnum<T>
setPermittedTypes(Collection<CtTypeReference<?>> permittedTypes)
Sets the permitted types for this type.<C extends CtType<T>>
CsetSuperclass(CtTypeReference<?> superClass)
Sets the superclass type.-
Methods inherited from class spoon.support.reflect.declaration.CtClassImpl
addAnonymousExecutable, addConstructor, getAllExecutables, getAnonymousExecutables, getConstructor, getConstructors, getDeclaredExecutables, getLabel, insertAfter, insertAfter, insertBefore, insertBefore, isAnonymous, newInstance, partiallyEvaluate, removeAnonymousExecutable, removeConstructor, setAnonymousExecutables, setConstructors, setLabel
-
Methods inherited from class spoon.support.reflect.declaration.CtTypeImpl
addField, addField, addFieldAtTop, addFormalCtTypeParameter, addFormalCtTypeParameterAt, addMethod, addModifier, addNestedType, addSuperInterface, addTypeMember, addTypeMemberAt, compileAndReplaceSnippets, copyType, getActualClass, getAllFields, getDeclaredField, getDeclaredFields, getDeclaredOrInheritedField, getDeclaringType, getExtendedModifiers, getMethods, getMethodsAnnotatedWith, getMethodsByName, getModifiers, getNestedType, getNestedTypes, getPackage, getQualifiedName, getReference, getSuperInterfaces, getTopLevelType, getTypeErasure, getTypeMembers, getUsedTypes, getVisibility, hasMethod, hasModifier, hasSameParameters, isAbstract, isAnnotationType, isArray, isFinal, isGenerics, isInterface, isLocalType, isNative, isParameterized, isPrimitive, isPrivate, isProtected, isPublic, isShadow, isStatic, isStrictfp, isSynchronized, isTopLevel, isTransient, isVolatile, removeField, removeFormalCtTypeParameter, removeMethod, removeModifier, removeNestedType, removeSuperInterface, removeTypeMember, setExtendedModifiers, setFields, setMethods, setModifiers, setNestedTypes, setShadow, setSimpleName, setSuperInterfaces, setTypeMembers, setVisibility, toStringWithImports
-
Methods inherited from class spoon.support.reflect.declaration.CtNamedElementImpl
getSimpleName
-
Methods inherited from class spoon.support.reflect.declaration.CtElementImpl
addAnnotation, addComment, asIterable, comment, delete, descendantIterator, emptyList, emptySet, equals, filterChildren, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getFactory, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hashCode, hasParent, isImplicit, isParentInitialized, map, map, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setFactory, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, unmodifiableList, updateAllParentsBelow
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface spoon.reflect.declaration.CtClass
addAnonymousExecutable, addConstructor, getAnonymousExecutables, getConstructor, getConstructors, isAnonymous, newInstance, removeAnonymousExecutable, removeConstructor, setAnonymousExecutables, setConstructors, setLabel
-
Methods inherited from interface spoon.reflect.code.CtCodeElement
partiallyEvaluate
-
Methods inherited from interface spoon.reflect.declaration.CtElement
addAnnotation, addComment, asIterable, delete, descendantIterator, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hasParent, isImplicit, isParentInitialized, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, updateAllParentsBelow
-
Methods inherited from interface spoon.reflect.declaration.CtFormalTypeDeclarer
addFormalCtTypeParameter, addFormalCtTypeParameterAt, removeFormalCtTypeParameter
-
Methods inherited from interface spoon.reflect.declaration.CtModifiable
addModifier, getExtendedModifiers, getModifiers, getVisibility, hasModifier, isAbstract, isFinal, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, removeModifier, setExtendedModifiers, setModifiers, setVisibility
-
Methods inherited from interface spoon.reflect.declaration.CtNamedElement
setSimpleName
-
Methods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, map
-
Methods inherited from interface spoon.reflect.declaration.CtShadowable
isShadow, setShadow
-
Methods inherited from interface spoon.reflect.code.CtStatement
comment, getLabel, insertAfter, insertAfter, insertBefore, insertBefore
-
Methods inherited from interface spoon.reflect.declaration.CtType
addField, addField, addFieldAtTop, addMethod, addNestedType, addSuperInterface, addTypeMember, addTypeMemberAt, compileAndReplaceSnippets, copyType, getActualClass, getMethods, getMethodsAnnotatedWith, getMethodsByName, getNestedType, getNestedTypes, getPackage, getReference, getSimpleName, getTypeMembers, getUsedTypes, hasMethod, isTopLevel, removeField, removeMethod, removeNestedType, removeSuperInterface, removeTypeMember, setFields, setMethods, setNestedTypes, setSuperInterfaces, setTypeMembers, toStringWithImports
-
Methods inherited from interface spoon.reflect.declaration.CtTypeInformation
getAllExecutables, getAllFields, getDeclaredExecutables, getDeclaredField, getDeclaredFields, getDeclaredOrInheritedField, getModifiers, getQualifiedName, getSuperInterfaces, getTypeErasure, isAnnotationType, isArray, isGenerics, isInterface, isLocalType, isParameterized, isPrimitive
-
Methods inherited from interface spoon.reflect.declaration.CtTypeMember
getDeclaringType, getTopLevelType
-
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
-
-
-
Method Detail
-
accept
public void accept(CtVisitor visitor)
Description copied from interface:CtVisitable
Accepts a visitor- Specified by:
accept
in interfaceCtVisitable
- Overrides:
accept
in classCtClassImpl<T extends Enum<?>>
-
getAllMethods
public Set<CtMethod<?>> getAllMethods()
Description copied from interface:CtType
Return all the methods that can be called on an instance of this type. It recursively collects all methods (both concrete and abstract) from all super-classes and all super-interfaces. It deduplicates methods with the same signature, which are defined several times somewhere in the type hierarchy. Warning: this method can be really slow due to signature deduplication. It includes all methods: the methods of types whose source code is in the Spoon model, the methods of types from the JDK and from libraries present in the classpath, the methods of java.lang.Object (for all CtClass objects). However, in noclasspath mode, it does not include methods from unknown types. If methods are overridden somewhere in the type hierarchy, it returns only top methods (ie method definitions).- Specified by:
getAllMethods
in interfaceCtType<T extends Enum<?>>
- Overrides:
getAllMethods
in classCtTypeImpl<T extends Enum<?>>
-
isSubtypeOf
public boolean isSubtypeOf(CtTypeReference<?> type)
Description copied from interface:CtTypeInformation
Returns true if the referenced type is a sub-type of the given type. Returns true is type is self, it means: typeX.isSubtypeOf(typeX) is true too- Specified by:
isSubtypeOf
in interfaceCtTypeInformation
- Overrides:
isSubtypeOf
in classCtClassImpl<T extends Enum<?>>
-
addEnumValue
public <C extends CtEnum<T>> C addEnumValue(CtEnumValue<?> enumValue)
Description copied from interface:CtEnum
Adds an enum value.- Specified by:
addEnumValue
in interfaceCtEnum<T extends Enum<?>>
- Parameters:
enumValue
- An enum value.- Returns:
- true if this element changed as a result of the call
-
removeEnumValue
public boolean removeEnumValue(CtEnumValue<?> enumValue)
Description copied from interface:CtEnum
Removes en enum value.- Specified by:
removeEnumValue
in interfaceCtEnum<T extends Enum<?>>
- Parameters:
enumValue
- An enum value.- Returns:
- true if this element changed as a result of the call
-
getEnumValue
public CtEnumValue<?> getEnumValue(String name)
Description copied from interface:CtEnum
Gets an enum value by its name.- Specified by:
getEnumValue
in interfaceCtEnum<T extends Enum<?>>
- Parameters:
name
- Name of the enum value.- Returns:
- An enum value.
-
getEnumValues
public List<CtEnumValue<?>> getEnumValues()
Description copied from interface:CtEnum
Gets all enum values of the enumeration.- Specified by:
getEnumValues
in interfaceCtEnum<T extends Enum<?>>
- Returns:
- All enum values.
-
setEnumValues
public <C extends CtEnum<T>> C setEnumValues(List<CtEnumValue<?>> enumValues)
Description copied from interface:CtEnum
Sets all enum values of the enum.- Specified by:
setEnumValues
in interfaceCtEnum<T extends Enum<?>>
-
getFields
public List<CtField<?>> getFields()
Description copied from interface:CtType
Returns the fields that are directly declared by this class or interface. Includes enum constants. Derived fromCtType.getTypeMembers()
-
getField
public CtField<?> getField(String name)
Description copied from interface:CtType
Gets a field from its name.
-
clone
public CtEnum<T> clone()
Description copied from interface:CtElement
Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methodsRefactoring.copyType(CtType)
andRefactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.- Specified by:
clone
in interfaceCtClass<T extends Enum<?>>
- Specified by:
clone
in interfaceCtCodeElement
- Specified by:
clone
in interfaceCtElement
- Specified by:
clone
in interfaceCtEnum<T extends Enum<?>>
- Specified by:
clone
in interfaceCtNamedElement
- Specified by:
clone
in interfaceCtStatement
- Specified by:
clone
in interfaceCtType<T extends Enum<?>>
- Overrides:
clone
in classCtClassImpl<T extends Enum<?>>
-
getPermittedTypes
public Set<CtTypeReference<?>> getPermittedTypes()
Description copied from interface:CtSealable
Returns the permitted types for this type.- Specified by:
getPermittedTypes
in interfaceCtEnum<T extends Enum<?>>
- Specified by:
getPermittedTypes
in interfaceCtSealable
- Overrides:
getPermittedTypes
in classCtClassImpl<T extends Enum<?>>
- Returns:
- an unmodifiable view of the permitted types.
-
setPermittedTypes
public CtEnum<T> setPermittedTypes(Collection<CtTypeReference<?>> permittedTypes)
Description copied from interface:CtSealable
Sets the permitted types for this type. Calling this method does not change the state of theModifierKind.SEALED
for this type. The previously permitted types will be removed.- Specified by:
setPermittedTypes
in interfaceCtEnum<T extends Enum<?>>
- Specified by:
setPermittedTypes
in interfaceCtSealable
- Overrides:
setPermittedTypes
in classCtClassImpl<T extends Enum<?>>
- Parameters:
permittedTypes
- the permitted types to set.- Returns:
- this.
-
addPermittedType
public CtEnum<T> addPermittedType(CtTypeReference<?> type)
Description copied from interface:CtSealable
Adds a permitted type to this type. Calling this method does not change the state of theModifierKind.SEALED
for this type.- Specified by:
addPermittedType
in interfaceCtEnum<T extends Enum<?>>
- Specified by:
addPermittedType
in interfaceCtSealable
- Overrides:
addPermittedType
in classCtClassImpl<T extends Enum<?>>
- Parameters:
type
- the type to add as permitted type.- Returns:
- this.
-
removePermittedType
public CtEnum<T> removePermittedType(CtTypeReference<?> type)
Description copied from interface:CtSealable
Adds a permitted type to this type. Calling this method does not change the state of theModifierKind.SEALED
for this type.- Specified by:
removePermittedType
in interfaceCtEnum<T extends Enum<?>>
- Specified by:
removePermittedType
in interfaceCtSealable
- Overrides:
removePermittedType
in classCtClassImpl<T extends Enum<?>>
- Parameters:
type
- the type to remove from this type's permitted types.- Returns:
- this.
-
getSuperclass
public CtTypeReference<?> getSuperclass()
Description copied from interface:CtTypeInformation
Returns the class type directly extended by this class. getSuperClass().getDeclaration()/getTypeDeclaration() returns the corresponding CtType (if in the source folder of Spoon).- Specified by:
getSuperclass
in interfaceCtTypeInformation
- Overrides:
getSuperclass
in classCtClassImpl<T extends Enum<?>>
- Returns:
- the class type directly extended by this class, or null if there is none or if the super class is not in the classpath (in noclasspath mode)
-
setSuperclass
public <C extends CtType<T>> C setSuperclass(CtTypeReference<?> superClass)
Description copied from interface:CtType
Sets the superclass type.- Specified by:
setSuperclass
in interfaceCtEnum<T extends Enum<?>>
- Specified by:
setSuperclass
in interfaceCtType<T extends Enum<?>>
- Overrides:
setSuperclass
in classCtClassImpl<T extends Enum<?>>
-
getMethod
public <R> CtMethod<R> getMethod(String name, CtTypeReference<?>... parameterTypes)
Description copied from interface:CtType
Gets a method from its name and parameter types.
-
getMethod
public <R> CtMethod<R> getMethod(CtTypeReference<R> returnType, String name, CtTypeReference<?>... parameterTypes)
Description copied from interface:CtType
Gets a method from its return type, name, and parameter types.
-
isClass
public boolean isClass()
Description copied from interface:CtTypeInformation
Returns true if this type is a class. Returns false for others (enum, interface, generics, annotation).- Specified by:
isClass
in interfaceCtTypeInformation
- Overrides:
isClass
in classCtClassImpl<T extends Enum<?>>
-
isEnum
public boolean isEnum()
Description copied from interface:CtTypeInformation
Returns true if this type is an enum.- Specified by:
isEnum
in interfaceCtTypeInformation
- Overrides:
isEnum
in classCtTypeImpl<T extends Enum<?>>
-
getFormalCtTypeParameters
public List<CtTypeParameter> getFormalCtTypeParameters()
Description copied from interface:CtFormalTypeDeclarer
Returns the formal type parameters of this generic element.- Specified by:
getFormalCtTypeParameters
in interfaceCtFormalTypeDeclarer
- Overrides:
getFormalCtTypeParameters
in classCtTypeImpl<T extends Enum<?>>
-
setFormalCtTypeParameters
public <C extends CtFormalTypeDeclarer> C setFormalCtTypeParameters(List<CtTypeParameter> formalTypeParameters)
Description copied from interface:CtFormalTypeDeclarer
Sets the type parameters of this generic element.- Specified by:
setFormalCtTypeParameters
in interfaceCtEnum<T extends Enum<?>>
- Specified by:
setFormalCtTypeParameters
in interfaceCtFormalTypeDeclarer
- Overrides:
setFormalCtTypeParameters
in classCtTypeImpl<T extends Enum<?>>
-
-