Class JavaGenericTypeFromSource

All Implemented Interfaces:
io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.element.CodeElement, io.github.mmm.code.api.element.CodeElementWithDeclaringType, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeItemWithComment, io.github.mmm.code.api.item.CodeItemWithDeclaration, io.github.mmm.code.api.item.CodeItemWithDeclaringType, io.github.mmm.code.api.item.CodeItemWithQualifiedFlag, io.github.mmm.code.api.item.CodeItemWithQualifiedName, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.item.CodeMutableItemWithComment, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.object.CodeMutable, io.github.mmm.code.api.type.CodeGenericType

public class JavaGenericTypeFromSource extends BaseGenericTypeProxy
BaseGenericTypeProxy used to create types from source code with lazy evaluation. In Java types can be referenced before they are actually declared (e.g. a nested class can be used in its parent class before it is defined in the source code). Therefore instances of this class can be created whilst parsing the source code and will be resolved via lazy initialization after the parsing has completed.
Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
  • Constructor Details

    • JavaGenericTypeFromSource

      public JavaGenericTypeFromSource(io.github.mmm.code.api.element.CodeElementWithTypeVariables parent, String name, BaseFile file)
      The constructor.
      Parameters:
      parent - the (potential) parent.
      name - the name of the type from the source code.
      file - the declaring BaseFile.
  • Method Details

    • getDelegate

      public BaseGenericType getDelegate()
      Specified by:
      getDelegate in class BaseGenericTypeProxy
    • getName

      public String getName()
      Returns:
      the raw name from source code.
    • isDiamonOperator

      public boolean isDiamonOperator()
      Returns:
      true if diamond operator (<>) was present in source-code for this type reference, false otherwise. E.g. needed for constructor references.
    • ensureTypeParameters

      public void ensureTypeParameters()
      Ensures that type parameters are initialized.
      See Also:
    • addTypeParameter

      public void addTypeParameter(BaseGenericType typeParameter)
      Parameters:
      typeParameter - the type parameter to add.
    • addComposedType

      public void addComposedType(BaseGenericType composedType)
      Parameters:
      composedType - the composed type to add.
    • getExtendsBound

      public BaseGenericType getExtendsBound()
      Returns:
      the upper bound of a wildcard or null.
    • setExtendsBound

      public void setExtendsBound(BaseGenericType extendsBound)
      Parameters:
      extendsBound - the new value of getExtendsBound().
    • getSuperBound

      public BaseGenericType getSuperBound()
      Returns:
      the lower bound of a wildcard or null.
    • setSuperBound

      public void setSuperBound(BaseGenericType superBound)
      Parameters:
      superBound - the new value of getSuperBound().
    • getArrayCount

      public int getArrayCount()
      Returns:
      the number of array dimensions. Will be zero (0) for no array.
    • setArrayCount

      public void setArrayCount(int arrayCount)
      Parameters:
      arrayCount - the new value of getArrayCount().
    • incArrayCount

      public void incArrayCount()
      Increments the array count.
    • getArrayLengthExpression

      public String getArrayLengthExpression()
      Returns:
      the length of the array (in case of an array initializer such as 1024 in new byte[1024] but may also be a variable, field reference, calculation expression, etc.) or null if not an array initializer.
    • setArrayLengthExpression

      public void setArrayLengthExpression(String arrayLengthExpression)
      Parameters:
      arrayLengthExpression - the new value of getArrayLengthExpression().
    • copy

      public BaseGenericType copy()
      Specified by:
      copy in interface io.github.mmm.code.api.element.CodeElement
      Specified by:
      copy in interface io.github.mmm.code.api.element.CodeElementWithDeclaringType
      Specified by:
      copy in interface io.github.mmm.code.api.type.CodeGenericType
      Specified by:
      copy in interface io.github.mmm.code.api.item.CodeMutableItem
      Specified by:
      copy in interface io.github.mmm.code.api.node.CodeNodeItem
      Specified by:
      copy in class BaseGenericType
    • copy

      public BaseGenericType copy(io.github.mmm.code.api.copy.CodeCopyMapper mapper)
      Specified by:
      copy in interface io.github.mmm.code.api.type.CodeGenericType
      Specified by:
      copy in interface io.github.mmm.code.api.item.CodeMutableItem
      Specified by:
      copy in interface io.github.mmm.code.api.node.CodeNodeItem
      Specified by:
      copy in class BaseGenericType