public final class Union extends GoloType<Union> implements ToplevelGoloElement
union element.
 For instance:
 union ConsList = {
   Empty
   Cons = {head, tail}
 }
 | Modifier and Type | Method and Description | 
|---|---|
void | 
accept(GoloIrVisitor visitor)
Accept the visitor. 
 | 
boolean | 
addElement(GoloElement<?> elt)
Adds a value or a macro invocation according to the given argument. 
 | 
boolean | 
addMacroInvocation(MacroInvocation macroCall)
Adds a macro invocation to this union. 
 | 
boolean | 
addValue(UnionValue value)
Adds a new value to this union. 
 | 
java.util.List<GoloElement<?>> | 
children()
Returns a list of all the direct children of this node. 
 | 
java.util.Collection<UnionValue> | 
getValues()  | 
protected void | 
replaceElement(GoloElement<?> original,
              GoloElement<?> newElement)
Replace a child. 
 | 
protected Union | 
self()  | 
static Union | 
union(java.lang.String name)
Creates a union type. 
 | 
Union | 
value(java.lang.String name,
     java.lang.Object... members)
Adds a new value to this union. 
 | 
getName, getPackageAndClassancestor, ancestor, ancestorOfType, cantConvert, cantReplace, cantReplace, children, children, descendants, descendants, descendants, documentation, documentation, doesNotContain, enclosingModule, getLocalReferenceTable, hasParent, hasPosition, inheritedMetadata, makeParentOf, metadata, metadata, next, next, next, ofAST, parent, positionInSourceCode, positionInSourceCode, previous, previous, previous, replaceInParentBy, walkpublic static Union union(java.lang.String name)
Typical usage:
 union("ConsList")
   .value("Empty")
   .value("Cons",
      "head",
      "tail")
 
 creates
 
 union ConsList = {
   Empty
   Cons = {head, tail}
 }
 name - the name of the union.protected Union self()
self in class GoloElement<Union>public boolean addValue(UnionValue value)
public boolean addMacroInvocation(MacroInvocation macroCall)
The macro is supposed to return a UnionValue when expanded.
 This allows decorator-like syntax on union values:
 
 union Foo = {
   @someMacro
   Value = {a, b}
   @otherMacro
   OtherValue
 }
 public boolean addElement(GoloElement<?> elt)
public java.util.Collection<UnionValue> getValues()
public Union value(java.lang.String name, java.lang.Object... members)
Convenient fluent method to add a new value.
This is a builder method.
public void accept(GoloIrVisitor visitor)
 This method should only call the visitor visitXXXX method.
 The children of this node will be visited by the
 GoloElement.walk(GoloIrVisitor) method.
accept in class GoloElement<Union>public java.util.List<GoloElement<?>> children()
children in class GoloElement<Union>protected void replaceElement(GoloElement<?> original, GoloElement<?> newElement)
 Replace original with newElement if original is a child of this node
 and type matches.
replaceElement in class GoloElement<Union>original - the original value to replace. Must be a child of this nodenewElement - the element to replace with. Type must match.GoloElement.cantReplace(), 
GoloElement.cantReplace(GoloElement, GoloElement), 
GoloElement.doesNotContain(GoloElement), 
GoloElement.cantConvert(String, Object)