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
ConstructorsConstructorDescriptionJavaGenericTypeFromSource(io.github.mmm.code.api.element.CodeElementWithTypeVariables parent, String name, io.github.mmm.code.base.BaseFile file) The constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComposedType(io.github.mmm.code.base.type.BaseGenericType composedType) voidaddTypeParameter(io.github.mmm.code.base.type.BaseGenericType typeParameter) io.github.mmm.code.base.type.BaseGenericTypecopy()io.github.mmm.code.base.type.BaseGenericTypecopy(io.github.mmm.code.api.copy.CodeCopyMapper mapper) voidEnsures thattype parametersare initialized.intio.github.mmm.code.base.type.BaseGenericTypeio.github.mmm.code.base.type.BaseGenericTypegetName()io.github.mmm.code.base.type.BaseGenericTypevoidIncrements thearray count.booleanvoidsetArrayCount(int arrayCount) voidsetArrayLengthExpression(String arrayLengthExpression) voidsetExtendsBound(io.github.mmm.code.base.type.BaseGenericType extendsBound) voidsetSuperBound(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, writeReferenceMethods inherited from class io.github.mmm.code.base.type.BaseGenericType
asComposedType, asTypePlaceholder, asTypeVariable, asTypeWildcard, asUnqualifiedType, createArray, getComponentType, getSourceCodeObject, isArray, isAssignableFromMethods inherited from class io.github.mmm.code.base.element.BaseElement
doInitialize, doMerge, doSetImmutable, doWriteAnnotations, doWriteComment, doWriteDoc, removeFromParent, setCommentMethods inherited from class io.github.mmm.code.base.node.BaseNodeItem
getContainerItem, getContainerItemDeclared, getContext, getLanguage, getSource, toPathStringMethods 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, writeItemMethods inherited from class io.github.mmm.code.base.item.BaseItem
getOwningType, getSourceCode, getSpaces, toString, writeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.mmm.code.api.element.CodeElement
removeFromParentMethods inherited from interface io.github.mmm.code.api.type.CodeGenericType
getCategory, isAnnotation, isAssignableTo, isClass, isEnumeration, isInterfaceMethods inherited from interface io.github.mmm.code.api.item.CodeItem
getLanguage, getSourceCode, write, write, write, write, write, writeMethods inherited from interface io.github.mmm.code.api.item.CodeItemWithDeclaration
writeReferenceMethods inherited from interface io.github.mmm.code.api.object.CodeMutable
isImmutable, isMutableMethods inherited from interface io.github.mmm.code.api.item.CodeMutableItem
setImmutableMethods inherited from interface io.github.mmm.code.api.item.CodeMutableItemWithComment
setCommentMethods 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 declaringBaseFile.
-
-
Method Details
-
getDelegate
public io.github.mmm.code.base.type.BaseGenericType getDelegate()- Specified by:
getDelegatein classio.github.mmm.code.base.type.BaseGenericTypeProxy
-
getName
- Returns:
- the raw name from source code.
-
isDiamonOperator
public boolean isDiamonOperator()- Returns:
trueif diamond operator (<>) was present in source-code for this type reference,falseotherwise. E.g. needed for constructor references.
-
ensureTypeParameters
public void ensureTypeParameters()Ensures thattype parametersare 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 ofgetExtendsBound().
-
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 ofgetSuperBound().
-
getArrayCount
public int getArrayCount()- Returns:
- the number of
arraydimensions. Will be zero (0) for no array.
-
setArrayCount
public void setArrayCount(int arrayCount) - Parameters:
arrayCount- the new value ofgetArrayCount().
-
incArrayCount
public void incArrayCount()Increments thearray count. -
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.) ornullif not an array initializer.
-
setArrayLengthExpression
- Parameters:
arrayLengthExpression- the new value ofgetArrayLengthExpression().
-
copy
public io.github.mmm.code.base.type.BaseGenericType copy()- Specified by:
copyin interfaceio.github.mmm.code.api.element.CodeElement- Specified by:
copyin interfaceio.github.mmm.code.api.element.CodeElementWithDeclaringType- Specified by:
copyin interfaceio.github.mmm.code.api.type.CodeGenericType- Specified by:
copyin interfaceio.github.mmm.code.api.item.CodeMutableItem- Specified by:
copyin interfaceio.github.mmm.code.api.node.CodeNodeItem- Specified by:
copyin classio.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:
copyin interfaceio.github.mmm.code.api.type.CodeGenericType- Specified by:
copyin interfaceio.github.mmm.code.api.item.CodeMutableItem- Specified by:
copyin interfaceio.github.mmm.code.api.node.CodeNodeItem- Specified by:
copyin classio.github.mmm.code.base.type.BaseGenericType
-