Class JavaGenericTypeFromSource

java.lang.Object
io.github.mmm.code.base.item.BaseItem
io.github.mmm.code.base.item.BaseMutableItem
io.github.mmm.code.base.node.BaseNodeItem
io.github.mmm.code.base.element.BaseElement
io.github.mmm.code.base.element.BaseElementWithDeclaringType
io.github.mmm.code.base.type.BaseGenericType
io.github.mmm.code.base.type.BaseGenericTypeProxy
io.github.mmm.code.impl.java.parser.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 io.github.mmm.code.base.type.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)
  • Field Summary

    Fields inherited from interface io.github.mmm.code.api.item.CodeItem

    DEFAULT_INDENT, DEFAULT_NEWLINE
  • Constructor Summary

    Constructors
    Constructor
    Description
    JavaGenericTypeFromSource(io.github.mmm.code.api.element.CodeElementWithTypeVariables parent, String name, io.github.mmm.code.base.BaseFile file)
    The constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addComposedType(io.github.mmm.code.base.type.BaseGenericType composedType)
     
    void
    addTypeParameter(io.github.mmm.code.base.type.BaseGenericType typeParameter)
     
    io.github.mmm.code.base.type.BaseGenericType
     
    io.github.mmm.code.base.type.BaseGenericType
    copy(io.github.mmm.code.api.copy.CodeCopyMapper mapper)
     
    void
    Ensures that type parameters are initialized.
    int
     
     
    io.github.mmm.code.base.type.BaseGenericType
     
    io.github.mmm.code.base.type.BaseGenericType
     
     
    io.github.mmm.code.base.type.BaseGenericType
     
    void
    Increments the array count.
    boolean
     
    void
    setArrayCount(int arrayCount)
     
    void
    setArrayLengthExpression(String arrayLengthExpression)
     
    void
    setExtendsBound(io.github.mmm.code.base.type.BaseGenericType extendsBound)
     
    void
    setSuperBound(io.github.mmm.code.base.type.BaseGenericType superBound)
     

    Methods inherited from class io.github.mmm.code.base.type.BaseGenericTypeProxy

    asType, doWrite, doWrite, getAnnotations, getAnnotations, getComment, getComment, getDeclaringType, getDoc, getParent, getQualifiedName, getReflectiveObject, getSimpleName, getTypeParameters, isQualified, resolve, writeReference

    Methods inherited from class io.github.mmm.code.base.type.BaseGenericType

    asComposedType, asTypePlaceholder, asTypeVariable, asTypeWildcard, asUnqualifiedType, createArray, getComponentType, getSourceCodeObject, isArray, isAssignableFrom

    Methods inherited from class io.github.mmm.code.base.element.BaseElement

    doInitialize, doMerge, doSetImmutable, doWriteAnnotations, doWriteComment, doWriteDoc, removeFromParent, setComment

    Methods inherited from class io.github.mmm.code.base.node.BaseNodeItem

    getContainerItem, getContainerItemDeclared, getContext, getLanguage, getSource, toPathString

    Methods inherited from class io.github.mmm.code.base.item.BaseMutableItem

    doCopyNode, doCopyNodeUnsafe, doMapList, doneInitialize, getDefaultCopyMapper, getDefaultEncoding, initialize, initialize, isImmutable, isInitialized, isInitializing, isSystemImmutable, isSystemImmutable, makeImmutable, makeImmutable, setImmutable, setImmutableIfNotSystemImmutable, verifyMutalbe, writeItem

    Methods inherited from class io.github.mmm.code.base.item.BaseItem

    getOwningType, getSourceCode, getSpaces, toString, write

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.github.mmm.code.api.element.CodeElement

    removeFromParent

    Methods inherited from interface io.github.mmm.code.api.type.CodeGenericType

    getCategory, isAnnotation, isAssignableTo, isClass, isEnumeration, isInterface

    Methods inherited from interface io.github.mmm.code.api.item.CodeItem

    getLanguage, getSourceCode, write, write, write, write, write, write

    Methods inherited from interface io.github.mmm.code.api.item.CodeItemWithDeclaration

    writeReference

    Methods inherited from interface io.github.mmm.code.api.object.CodeMutable

    isImmutable, isMutable

    Methods inherited from interface io.github.mmm.code.api.item.CodeMutableItem

    setImmutable

    Methods inherited from interface io.github.mmm.code.api.item.CodeMutableItemWithComment

    setComment

    Methods inherited from interface io.github.mmm.code.api.CodeWithContext

    getContext, getSource
  • Constructor Details

    • JavaGenericTypeFromSource

      public JavaGenericTypeFromSource(io.github.mmm.code.api.element.CodeElementWithTypeVariables parent, String name, io.github.mmm.code.base.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 io.github.mmm.code.base.type.BaseGenericType getDelegate()
      Specified by:
      getDelegate in class io.github.mmm.code.base.type.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(io.github.mmm.code.base.type.BaseGenericType typeParameter)
      Parameters:
      typeParameter - the type parameter to add.
    • addComposedType

      public void addComposedType(io.github.mmm.code.base.type.BaseGenericType composedType)
      Parameters:
      composedType - the composed type to add.
    • getExtendsBound

      public io.github.mmm.code.base.type.BaseGenericType getExtendsBound()
      Returns:
      the upper bound of a wildcard or null.
    • setExtendsBound

      public void setExtendsBound(io.github.mmm.code.base.type.BaseGenericType extendsBound)
      Parameters:
      extendsBound - the new value of getExtendsBound().
    • getSuperBound

      public io.github.mmm.code.base.type.BaseGenericType getSuperBound()
      Returns:
      the lower bound of a wildcard or null.
    • setSuperBound

      public void setSuperBound(io.github.mmm.code.base.type.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 io.github.mmm.code.base.type.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 io.github.mmm.code.base.type.BaseGenericType
    • copy

      public io.github.mmm.code.base.type.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 io.github.mmm.code.base.type.BaseGenericType