Top Description Fields Constructors Methods
org.codehaus.groovy.transform.stc

pack-priv Class UnionTypeClassNode

extends ClassNode
Class Inheritance
Imports
org.codehaus.groovy.ast.ASTNode, .AnnotationNode, .ClassNode, .ConstructorNode, .FieldNode, .GenericsType, .GroovyClassVisitor, .InnerClassNode, .MethodNode, .MixinNode, .Parameter, .PropertyNode, org.codehaus.groovy.ast.expr.Expression, org.codehaus.groovy.ast.stmt.Statement, org.codehaus.groovy.transform.ASTTransformation, java.util.Arrays, .Collections, .HashSet, .Iterator, .LinkedHashSet, .LinkedList, .List, .Map, .Set, .StringJoiner

This class node type is very special and should only be used by the static type checker to represent types which are the union of other types. This is useful when, for example, we enter a section like :
if (x instanceof A || x instanceof B)
where the type of x can be represented as one of A or B. This class node type should never leak outside of the type checker. More precisely, it should only be used to check method call arguments, and nothing more.

Field Summary

Modifier and TypeField and Description
private final ClassNode[]
Inherited from org.codehaus.groovy.ast.ClassNode:
clazzEMPTY_ARRAYinnerClassesisPrimaryNodelazyInitLockSUPERTHIS

Constructor Summary

AccessConstructor and Description
pack-priv
UnionTypeClassNode(final ClassNode... classNodes)

Method Summary

Modifier and TypeMethod and Description
public ConstructorNode
addConstructor(final int modifiers, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Overrides org.codehaus.groovy.ast.ClassNode.addConstructor.

public void
public FieldNode
addField(final String name, final int modifiers, final ClassNode type, final Expression initialValue)

Overrides org.codehaus.groovy.ast.ClassNode.addField.

public void
public FieldNode
addFieldFirst(final String name, final int modifiers, final ClassNode type, final Expression initialValue)

Overrides org.codehaus.groovy.ast.ClassNode.addFieldFirst.

public void
public void
public MethodNode
addMethod(final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Overrides org.codehaus.groovy.ast.ClassNode.addMethod.

If a method with the given name and parameters is already defined then it is returned otherwise the given method is added to this node.
public void
public void
public void
addObjectInitializerStatements(final Statement
the statement to be added
statements
)

Overrides org.codehaus.groovy.ast.ClassNode.addObjectInitializerStatements.

Adds a statement to the object initializer.
public PropertyNode
addProperty(final String name, final int modifiers, final ClassNode type, final Expression initialValueExpression, final Statement getterBlock, final Statement setterBlock)

Overrides org.codehaus.groovy.ast.ClassNode.addProperty.

public void
public void
public MethodNode
addSyntheticMethod(final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Overrides org.codehaus.groovy.ast.ClassNode.addSyntheticMethod.

Adds a synthetic method as part of the compilation process.
public void
public boolean
declaresInterface(final ClassNode
the class node for the interface
classNode
)

Overrides org.codehaus.groovy.ast.ClassNode.declaresInterface.

public List<MethodNode>
public List<MethodNode>
public Set<ClassNode>
public List<AnnotationNode>
public List<AnnotationNode>
public ClassNode
public List<ConstructorNode>
public FieldNode
getDeclaredField(final String
the name of the field of interest
name
)

Overrides org.codehaus.groovy.ast.ClassNode.getDeclaredField.

Finds a field matching the given name in this class.
public MethodNode
getDeclaredMethod(final String name, final Parameter[] parameters)

Overrides org.codehaus.groovy.ast.ClassNode.getDeclaredMethod.

Finds a method matching the given name and parameters in this class.
public List<MethodNode>
getDeclaredMethods(final String name)

Overrides org.codehaus.groovy.ast.ClassNode.getDeclaredMethods.

This method returns a list of all methods of the given name defined in the current class
public Map<String, MethodNode>
public ClassNode[]
public MethodNode
public FieldNode
getField(final String
the name of the field of interest
name
)

Overrides org.codehaus.groovy.ast.ClassNode.getField.

Finds a field matching the given name in this class or a parent class.
public List<FieldNode>
public Iterator<InnerClassNode>
public ClassNode[]
public List<MethodNode>
public ClassNode
public List<PropertyNode>
public Class<T>
getTypeClass()

Overrides org.codehaus.groovy.ast.ClassNode.getTypeClass.

Returns the concrete class this classnode relates to.
public ClassNode[]
public ClassNode[]
public int
hashCode()

Overrides org.codehaus.groovy.ast.ClassNode.hashCode.

Returns a hash code value for the object.
public boolean
implementsInterface(final ClassNode
the class node for the interface
classNode
)

Overrides org.codehaus.groovy.ast.ClassNode.implementsInterface.

public boolean
public boolean
isDerivedFrom(final ClassNode
the ClassNode of interest
type
)

Overrides org.codehaus.groovy.ast.ClassNode.isDerivedFrom.

public boolean
private static String
makeName(final ClassNode[] nodes)

private static ClassNode
makeSuper(final ClassNode[] nodes)

public void
public void
public void
setAnnotated(final boolean flag)

Overrides org.codehaus.groovy.ast.ClassNode.setAnnotated.

Marks if the current class uses annotations or not.
public void
public void
public void
public void
public void
public String
public void
setRedirect(final ClassNode
the class to redirect to; if null the redirect is removed
cn
)

Overrides org.codehaus.groovy.ast.ClassNode.setRedirect.

Sets this instance as proxy for the given ClassNode.
public void
public void
public void
public void
setSuperClass(final ClassNode superClass)

Overrides org.codehaus.groovy.ast.ClassNode.setSuperClass.

Sets the superclass of this ClassNode.
public void
public void
public void
public void
Inherited from org.codehaus.groovy.ast.ClassNode:
asGenericsTypedeclaresAnyInterfacesequalsgetCompileUnitgetDeclaredConstructorgetFieldIndexgetGenericsTypesgetGetterMethodgetGetterMethodgetMethodgetMethodsgetMixinsgetModifiersgetModulegetNamegetNameWithoutPackagegetObjectInitializerStatementsgetOuterClassgetOuterClassesgetOuterFieldgetPackagegetPackageNamegetPropertygetSetterMethodgetSetterMethodgetSuperClassgetTextgetTransformsgetUnresolvedNamegetUnresolvedSuperClassgetUnresolvedSuperClasshasDeclaredMethodhasMethodhasPackageNamehasPossibleMethodhasPossibleStaticMethodhasPropertyimplementsAnyInterfacesisAbstractisAnnotationDefinitionisArrayisEnumisGenericsPlaceHolderisInterfaceisPrimaryClassNodeisRedirectNodeisResolvedisScriptisScriptBodyisStaticClassisSyntheticPublicisUsingGenericsmakeArrayparametersEqualpositionStmtsAfterEnumInitStmtsredirectremoveConstructorremoveMethodsetCompileUnitsetMixinssetModuletoStringtoStringtryFindPossibleMethod

Field Detail

delegatesback to summary
private final ClassNode[] delegates

Constructor Detail

UnionTypeClassNodeback to summary
pack-priv UnionTypeClassNode(final ClassNode... classNodes)

Method Detail

addConstructorback to summary
public ConstructorNode addConstructor(final int modifiers, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Overrides org.codehaus.groovy.ast.ClassNode.addConstructor.

Annotations
@Override
addConstructorback to summary
public void addConstructor(final ConstructorNode node)

Overrides org.codehaus.groovy.ast.ClassNode.addConstructor.

Annotations
@Override
addFieldback to summary
public FieldNode addField(final String name, final int modifiers, final ClassNode type, final Expression initialValue)

Overrides org.codehaus.groovy.ast.ClassNode.addField.

Annotations
@Override
addFieldback to summary
public void addField(final FieldNode node)

Overrides org.codehaus.groovy.ast.ClassNode.addField.

Annotations
@Override
addFieldFirstback to summary
public FieldNode addFieldFirst(final String name, final int modifiers, final ClassNode type, final Expression initialValue)

Overrides org.codehaus.groovy.ast.ClassNode.addFieldFirst.

Annotations
@Override
addFieldFirstback to summary
public void addFieldFirst(final FieldNode node)

Overrides org.codehaus.groovy.ast.ClassNode.addFieldFirst.

Annotations
@Override
addInterfaceback to summary
public void addInterface(final ClassNode type)

Overrides org.codehaus.groovy.ast.ClassNode.addInterface.

Annotations
@Override
addMethodback to summary
public MethodNode addMethod(final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Overrides org.codehaus.groovy.ast.ClassNode.addMethod.

Doc from org.codehaus.groovy.ast.ClassNode.addMethod.

If a method with the given name and parameters is already defined then it is returned otherwise the given method is added to this node. This method is useful for default method adding like getProperty() or invokeMethod() where there may already be a method defined in a class and so the default implementations should not be added if already present.

Annotations
@Override
addMethodback to summary
public void addMethod(final MethodNode node)

Overrides org.codehaus.groovy.ast.ClassNode.addMethod.

Annotations
@Override
addMixinback to summary
public void addMixin(final MixinNode mixin)

Overrides org.codehaus.groovy.ast.ClassNode.addMixin.

Annotations
@Override
addObjectInitializerStatementsback to summary
public void addObjectInitializerStatements(final Statement statements)

Overrides org.codehaus.groovy.ast.ClassNode.addObjectInitializerStatements.

Doc from org.codehaus.groovy.ast.ClassNode.addObjectInitializerStatements.

Adds a statement to the object initializer.

Parameters
statements:Statement

the statement to be added

Annotations
@Override
addPropertyback to summary
public PropertyNode addProperty(final String name, final int modifiers, final ClassNode type, final Expression initialValueExpression, final Statement getterBlock, final Statement setterBlock)

Overrides org.codehaus.groovy.ast.ClassNode.addProperty.

Annotations
@Override
addPropertyback to summary
public void addProperty(final PropertyNode node)

Overrides org.codehaus.groovy.ast.ClassNode.addProperty.

Annotations
@Override
addStaticInitializerStatementsback to summary
public void addStaticInitializerStatements(final List<Statement> staticStatements, final boolean fieldInit)

Overrides org.codehaus.groovy.ast.ClassNode.addStaticInitializerStatements.

Annotations
@Override
addSyntheticMethodback to summary
public MethodNode addSyntheticMethod(final String name, final int modifiers, final ClassNode returnType, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code)

Overrides org.codehaus.groovy.ast.ClassNode.addSyntheticMethod.

Doc from org.codehaus.groovy.ast.ClassNode.addSyntheticMethod.

Adds a synthetic method as part of the compilation process.

Annotations
@Override
addTransformback to summary
public void addTransform(final Class<? extends ASTTransformation> transform, final ASTNode node)

Overrides org.codehaus.groovy.ast.ClassNode.addTransform.

Annotations
@Override
declaresInterfaceback to summary
public boolean declaresInterface(final ClassNode classNode)

Overrides org.codehaus.groovy.ast.ClassNode.declaresInterface.

Parameters
classNode:ClassNode

Doc from org.codehaus.groovy.ast.ClassNode.declaresInterface.

the class node for the interface

Returns:boolean

Doc from org.codehaus.groovy.ast.ClassNode.declaresInterface.

true if this class declares that it implements the given interface or if one of its interfaces extends directly/indirectly the interface NOTE: Doesn't consider an interface to implement itself. I think this is intended to be called on ClassNodes representing classes, not interfaces.

Annotations
@Override
getAbstractMethodsback to summary
public List<MethodNode> getAbstractMethods()

Overrides org.codehaus.groovy.ast.ClassNode.getAbstractMethods.

Returns:List<MethodNode>

Doc from org.codehaus.groovy.ast.ClassNode.getAbstractMethods.

the abstract methods associated with this ClassNode

Annotations
@Override
getAllDeclaredMethodsback to summary
public List<MethodNode> getAllDeclaredMethods()

Overrides org.codehaus.groovy.ast.ClassNode.getAllDeclaredMethods.

Annotations
@Override
getAllInterfacesback to summary
public Set<ClassNode> getAllInterfaces()

Overrides org.codehaus.groovy.ast.ClassNode.getAllInterfaces.

Annotations
@Override
getAnnotationsback to summary
public List<AnnotationNode> getAnnotations()

Overrides org.codehaus.groovy.ast.ClassNode.getAnnotations.

Annotations
@Override
getAnnotationsback to summary
public List<AnnotationNode> getAnnotations(final ClassNode type)

Overrides org.codehaus.groovy.ast.ClassNode.getAnnotations.

Annotations
@Override
getComponentTypeback to summary
public ClassNode getComponentType()

Overrides org.codehaus.groovy.ast.ClassNode.getComponentType.

Annotations
@Override
getDeclaredConstructorsback to summary
public List<ConstructorNode> getDeclaredConstructors()

Overrides org.codehaus.groovy.ast.ClassNode.getDeclaredConstructors.

Annotations
@Override
getDeclaredFieldback to summary
public FieldNode getDeclaredField(final String name)

Overrides org.codehaus.groovy.ast.ClassNode.getDeclaredField.

Doc from org.codehaus.groovy.ast.ClassNode.getDeclaredField.

Finds a field matching the given name in this class.

Parameters
name:String

the name of the field of interest

Returns:FieldNode

the method matching the given name and parameters or null

Annotations
@Override
getDeclaredMethodback to summary
public MethodNode getDeclaredMethod(final String name, final Parameter[] parameters)

Overrides org.codehaus.groovy.ast.ClassNode.getDeclaredMethod.

Doc from org.codehaus.groovy.ast.ClassNode.getDeclaredMethod.

Finds a method matching the given name and parameters in this class.

Returns:MethodNode

the method matching the given name and parameters or null

Annotations
@Override
getDeclaredMethodsback to summary
public List<MethodNode> getDeclaredMethods(final String name)

Overrides org.codehaus.groovy.ast.ClassNode.getDeclaredMethods.

Doc from org.codehaus.groovy.ast.ClassNode.getDeclaredMethods.

This method returns a list of all methods of the given name defined in the current class

Returns:List<MethodNode>

the method list

Annotations
@Override
getDeclaredMethodsMapback to summary
public Map<String, MethodNode> getDeclaredMethodsMap()

Overrides org.codehaus.groovy.ast.ClassNode.getDeclaredMethodsMap.

Annotations
@Override
getDelegatesback to summary
public ClassNode[] getDelegates()
getEnclosingMethodback to summary
public MethodNode getEnclosingMethod()

Overrides org.codehaus.groovy.ast.ClassNode.getEnclosingMethod.

Annotations
@Override
getFieldback to summary
public FieldNode getField(final String name)

Overrides org.codehaus.groovy.ast.ClassNode.getField.

Doc from org.codehaus.groovy.ast.ClassNode.getField.

Finds a field matching the given name in this class or a parent class.

Parameters
name:String

the name of the field of interest

Returns:FieldNode

the method matching the given name and parameters or null

Annotations
@Override
getFieldsback to summary
public List<FieldNode> getFields()

Overrides org.codehaus.groovy.ast.ClassNode.getFields.

Returns:List<FieldNode>

Doc from org.codehaus.groovy.ast.ClassNode.getFields.

the fields associated with this ClassNode

Annotations
@Override
getInnerClassesback to summary
public Iterator<InnerClassNode> getInnerClasses()

Overrides org.codehaus.groovy.ast.ClassNode.getInnerClasses.

Returns:Iterator<InnerClassNode>

Doc from org.codehaus.groovy.ast.ClassNode.getInnerClasses.

iterator of inner classes defined inside this one

Annotations
@Override
getInterfacesback to summary
public ClassNode[] getInterfaces()

Overrides org.codehaus.groovy.ast.ClassNode.getInterfaces.

Returns:ClassNode[]

Doc from org.codehaus.groovy.ast.ClassNode.getInterfaces.

the interfaces implemented by this ClassNode

Annotations
@Override
getMethodsback to summary
public List<MethodNode> getMethods()

Overrides org.codehaus.groovy.ast.ClassNode.getMethods.

Returns:List<MethodNode>

Doc from org.codehaus.groovy.ast.ClassNode.getMethods.

the methods associated with this ClassNode

Annotations
@Override
getPlainNodeReferenceback to summary
public ClassNode getPlainNodeReference()

Overrides org.codehaus.groovy.ast.ClassNode.getPlainNodeReference.

Annotations
@Override
getPropertiesback to summary
public List<PropertyNode> getProperties()

Overrides org.codehaus.groovy.ast.ClassNode.getProperties.

Annotations
@Override
getTypeClassback to summary
public Class<T> getTypeClass()

Overrides org.codehaus.groovy.ast.ClassNode.getTypeClass.

Doc from org.codehaus.groovy.ast.ClassNode.getTypeClass.

Returns the concrete class this classnode relates to. However, this method is inherently unsafe as it may return null depending on the compile phase you are using. AST transformations should never use this method directly, but rather obtain a new class node using getPlainNodeReference().

Returns:Class<T>

the class this classnode relates to. May return null.

Annotations
@Override
getUnresolvedInterfacesback to summary
public ClassNode[] getUnresolvedInterfaces()

Overrides org.codehaus.groovy.ast.ClassNode.getUnresolvedInterfaces.

Annotations
@Override
getUnresolvedInterfacesback to summary
public ClassNode[] getUnresolvedInterfaces(final boolean useRedirect)

Overrides org.codehaus.groovy.ast.ClassNode.getUnresolvedInterfaces.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides org.codehaus.groovy.ast.ClassNode.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
implementsInterfaceback to summary
public boolean implementsInterface(final ClassNode classNode)

Overrides org.codehaus.groovy.ast.ClassNode.implementsInterface.

Parameters
classNode:ClassNode

Doc from org.codehaus.groovy.ast.ClassNode.implementsInterface.

the class node for the interface

Returns:boolean

Doc from org.codehaus.groovy.ast.ClassNode.implementsInterface.

true if this type implements the given interface

Annotations
@Override
isAnnotatedback to summary
public boolean isAnnotated()

Overrides org.codehaus.groovy.ast.ClassNode.isAnnotated.

Annotations
@Override
isDerivedFromback to summary
public boolean isDerivedFrom(final ClassNode type)

Overrides org.codehaus.groovy.ast.ClassNode.isDerivedFrom.

Parameters
type:ClassNode

Doc from org.codehaus.groovy.ast.ClassNode.isDerivedFrom.

the ClassNode of interest

Returns:boolean

Doc from org.codehaus.groovy.ast.ClassNode.isDerivedFrom.

true if this node is derived from the given ClassNode

Annotations
@Override
isDerivedFromGroovyObjectback to summary
public boolean isDerivedFromGroovyObject()

Overrides org.codehaus.groovy.ast.ClassNode.isDerivedFromGroovyObject.

Returns:boolean

Doc from org.codehaus.groovy.ast.ClassNode.isDerivedFromGroovyObject.

true if this type implements GroovyObject

Annotations
@Override
makeNameback to summary
private static String makeName(final ClassNode[] nodes)
makeSuperback to summary
private static ClassNode makeSuper(final ClassNode[] nodes)
removeFieldback to summary
public void removeField(final String oldName)

Overrides org.codehaus.groovy.ast.ClassNode.removeField.

Annotations
@Override
renameFieldback to summary
public void renameField(final String oldName, final String newName)

Overrides org.codehaus.groovy.ast.ClassNode.renameField.

Annotations
@Override
setAnnotatedback to summary
public void setAnnotated(final boolean flag)

Overrides org.codehaus.groovy.ast.ClassNode.setAnnotated.

Doc from org.codehaus.groovy.ast.ClassNode.setAnnotated.

Marks if the current class uses annotations or not.

Annotations
@Override
setEnclosingMethodback to summary
public void setEnclosingMethod(final MethodNode enclosingMethod)

Overrides org.codehaus.groovy.ast.ClassNode.setEnclosingMethod.

Annotations
@Override
setGenericsPlaceHolderback to summary
public void setGenericsPlaceHolder(final boolean b)

Overrides org.codehaus.groovy.ast.ClassNode.setGenericsPlaceHolder.

Annotations
@Override
setGenericsTypesback to summary
public void setGenericsTypes(final GenericsType[] genericsTypes)

Overrides org.codehaus.groovy.ast.ClassNode.setGenericsTypes.

Annotations
@Override
setInterfacesback to summary
public void setInterfaces(final ClassNode[] interfaces)

Overrides org.codehaus.groovy.ast.ClassNode.setInterfaces.

Annotations
@Override
setModifiersback to summary
public void setModifiers(final int modifiers)

Overrides org.codehaus.groovy.ast.ClassNode.setModifiers.

Annotations
@Override
setNameback to summary
public String setName(final String name)

Overrides org.codehaus.groovy.ast.ClassNode.setName.

Annotations
@Override
setRedirectback to summary
public void setRedirect(final ClassNode cn)

Overrides org.codehaus.groovy.ast.ClassNode.setRedirect.

Doc from org.codehaus.groovy.ast.ClassNode.setRedirect.

Sets this instance as proxy for the given ClassNode.

Parameters
cn:ClassNode

the class to redirect to; if null the redirect is removed

Annotations
@Override
setScriptback to summary
public void setScript(final boolean script)

Overrides org.codehaus.groovy.ast.ClassNode.setScript.

Annotations
@Override
setScriptBodyback to summary
public void setScriptBody(final boolean scriptBody)

Overrides org.codehaus.groovy.ast.ClassNode.setScriptBody.

Annotations
@Override
setStaticClassback to summary
public void setStaticClass(final boolean staticClass)

Overrides org.codehaus.groovy.ast.ClassNode.setStaticClass.

Annotations
@Override
setSuperClassback to summary
public void setSuperClass(final ClassNode superClass)

Overrides org.codehaus.groovy.ast.ClassNode.setSuperClass.

Doc from org.codehaus.groovy.ast.ClassNode.setSuperClass.

Sets the superclass of this ClassNode.

Annotations
@Override
setSyntheticPublicback to summary
public void setSyntheticPublic(final boolean syntheticPublic)

Overrides org.codehaus.groovy.ast.ClassNode.setSyntheticPublic.

Annotations
@Override
setUnresolvedSuperClassback to summary
public void setUnresolvedSuperClass(final ClassNode sn)

Overrides org.codehaus.groovy.ast.ClassNode.setUnresolvedSuperClass.

Annotations
@Override
setUsingGenericsback to summary
public void setUsingGenerics(final boolean b)

Overrides org.codehaus.groovy.ast.ClassNode.setUsingGenerics.

Annotations
@Override
visitContentsback to summary
public void visitContents(final GroovyClassVisitor visitor)

Overrides org.codehaus.groovy.ast.ClassNode.visitContents.

Annotations
@Override