Class WideningCategories.LowestUpperBoundClassNode

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.ClassNode
org.codehaus.groovy.ast.tools.WideningCategories.LowestUpperBoundClassNode
All Implemented Interfaces:
GroovydocHolder<AnnotatedNode>, NodeMetaDataHandler
Enclosing class:
WideningCategories

public static class WideningCategories.LowestUpperBoundClassNode extends ClassNode
This ClassNode specialization is used when the lowest upper bound of two types cannot be represented by an existing type. For example, if B extends A, C extends A and both C and B implement a common interface not implemented by A, then we use this class to represent the bound.

At compile time, some classes like AsmClassGenerator need to know about a real class node, so we compute a "compile time" node which will be used to return a name and a type class.

  • Constructor Details

    • LowestUpperBoundClassNode

      public LowestUpperBoundClassNode(String name, ClassNode upper, ClassNode... interfaces)
      Builds a public final type named name whose superclass is upper and whose interfaces are interfaces. The interfaces are sorted by name. The printed form joins the upper type and the interfaces with &, omitting Object. When upper is Object and at least one interface is present, the compile-time stand-in is the first interface after that sort; otherwise it is upper. Generics from the upper type and the interfaces are copied here when this node uses generics.
      Parameters:
      name - internal name of the synthetic bound
      upper - superclass of the bound
      interfaces - interfaces of the bound
  • Method Details

    • getLubName

      public String getLubName()
      Returns the internal name passed to the constructor.
      Returns:
      the unresolved name of this bound
    • getText

      public String getText()
      Description copied from class: ASTNode
      Returns a human-readable text representation of this AST node. Used for debugging and error messages. Default implementation returns a message indicating the representation is not yet implemented for this node type.
      Overrides:
      getText in class ClassNode
      Returns:
      text representation of this node, or placeholder for unimplemented types
    • getName

      public String getName()
      Description copied from class: ClassNode
      Returns the fully-qualified name of this class after following any redirects. If this ClassNode is a proxy for another ClassNode, the name of the target is returned. The name remains consistent across all compilation phases for the redirected type.
      Overrides:
      getName in class ClassNode
      Returns:
      the fully-qualified class name (e.g., "com.example.MyClass" or "int[]")
    • getTypeClass

      public Class getTypeClass()
      Description copied from class: ClassNode
      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 ClassNode.getPlainNodeReference().
      Overrides:
      getTypeClass in class ClassNode
      Returns:
      the class this classnode relates to. May return null.
    • toString

      public String toString(boolean x)
      Description copied from class: ClassNode
      Returns a string representation of this ClassNode with optional redirect information. For array types, appends "[]" to the component type's string representation. For generic types, includes generic type parameters (e.g., "List"). If showRedirect is true and this is a redirect node, includes arrow notation showing the redirect target; otherwise the redirect information is omitted.
      Overrides:
      toString in class ClassNode
      Parameters:
      x - if true, includes redirect information in the output; if false, omits it
      Returns:
      a string representation of this ClassNode
    • asGenericsType

      public GenericsType asGenericsType()
      Description copied from class: ClassNode
      Views this node as a generic type argument. A node that is not a type-variable placeholder becomes a generics type with no bounds. A placeholder whose stored generics type already has upper bounds returns that same object. Otherwise a new generics type is built with this node as the type variable and the redirect, or this node when there is no redirect, as its upper bound. A generic declaration already stored on the placeholder is copied onto that new type.
      Overrides:
      asGenericsType in class ClassNode
      Returns:
      a generics type representing this node
    • getPlainNodeReference

      public ClassNode getPlainNodeReference()
      Description copied from class: ClassNode
      Returns a non-primary proxy that redirects to ClassNode.redirect(), so generics or type annotations can be added without mutating the canonical class. A primitive is returned as this. Use ClassNode.getPlainNodeReference(boolean) to force a proxy for a primitive.
      Overrides:
      getPlainNodeReference in class ClassNode
      Returns:
      this node when it is a primitive, otherwise a new redirecting proxy