Interface CodePathElements
- All Superinterfaces:
CodeItem, CodeMutable, CodeMutableItem, CodeNode, CodeNodeContainer<CodePathElement>, CodeNodeItem, CodeNodeItemContainer<CodePathElement>, CodeNodeItemContainerFlat<CodePathElement>, CodeNodeItemCopyable<CodePackage, CodePathElements>, CodeWithContext, Iterable<CodePathElement>
public interface CodePathElements
extends CodeNodeItemContainerFlat<CodePathElement>, CodeNodeItemCopyable<CodePackage, CodePathElements>
- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
Field Summary
Fields inherited from interface CodeItem
DEFAULT_INDENT, DEFAULT_NEWLINE -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(CodePathElement child) Attention: This method is only for advanced usage.booleancontainsPackage(CodePackage child) booleancontainsSubPackage(CodePackage child) copy()copy(CodeCopyMapper mapper) createFile(String simpleName) Attention: This method is just a factory operation.createPackage(String simpleName) Attention: This method is just a factory operation.createType(String simpleName) Attention: This method is just a factory operation.List<? extends CodePathElement> Attention:
This method can trigger expensive classpath scanning (or filesystem traversal) on its first call.getOrCreateFile(CodeName path, boolean add) default CodeFilegetOrCreateFile(String path) getOrCreatePackage(CodeName path, boolean add) default CodePackagegetOrCreatePackage(String path) getPackage(CodeName path) getPackage(String simpleName) Methods inherited from interface CodeItem
getLanguage, getSourceCode, write, write, write, write, write, writeMethods inherited from interface CodeMutable
isImmutable, isMutableMethods inherited from interface CodeMutableItem
getReflectiveObject, setImmutableMethods inherited from interface CodeNodeContainer
isEmpty, iteratorMethods inherited from interface CodeNodeItemContainer
removeMethods inherited from interface CodeWithContext
getContext, getSourceMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
getParent
CodePackage getParent()- Specified by:
getParentin interfaceCodeNode- Specified by:
getParentin interfaceCodeNodeItemContainer<CodePathElement>- Specified by:
getParentin interfaceCodeNodeItemCopyable<CodePackage, CodePathElements>- Returns:
- the parent of this
CodeNode. May only benullfor instances ofCodeContext.
-
getDeclared
List<? extends CodePathElement> getDeclared()Attention:
This method can trigger expensive classpath scanning (or filesystem traversal) on its first call.- Specified by:
getDeclaredin interfaceCodeNodeContainer<CodePathElement>- Returns:
- all items directly contained in this container.
-
get
- Parameters:
simpleName- thesimple nameof the requestedCodePathElement.- Returns:
- the
CodePathElementfromall itemswith the givennameornullif not found.
-
getFile
- Parameters:
simpleName- thesimple nameof the requestedCodeFile.- Returns:
- the
CodeFilewith the givennameornullif not found.
-
getFile
-
createFile
Attention: This method is just a factory operation. It will not add the createdCodeFile. UsegetOrCreateFile(String)instead to also add.- Parameters:
simpleName- thesimple nameof the newCodeFile.- Returns:
- a new
CodeFilecontaining an empty top-levelCodeTypeof the same name.
-
getOrCreateFile
-
getOrCreateFile
- Parameters:
path- theCodeNameleading to the requested child relative to thepackage of this children. Will typically be invoked on thechildrenof aroot packagewith aqualified nameparsed viaCodeProvider.parseName(String).add- -trueto add a newly createdCodeFile,falseotherwise.- Returns:
- the
existingornewly createdCodeFile.
-
getPackage
- Parameters:
simpleName- thesimple nameof the requestedCodePackage.- Returns:
- the
CodePackagewith the givennameornullif not found.
-
getPackage
- Parameters:
path- theCodeNameleading to the requested child relative to thepackage of this children. Will typically be invoked on thechildrenof aroot packagewith aqualified nameparsed viaCodeProvider.parseName(String).- Returns:
- the traversed
CodePackageornullif not found.
-
getOrCreatePackage
- Parameters:
path- theCodeNameleading to the requested child relative to thepackage of this children. Will typically be invoked on thechildrenof aroot packagewith aqualified nameparsed viaCodeProvider.parseName(String).add- -trueto add newly created packages,falseotherwise.- Returns:
- the traversed
CodePackage. Has been created if it did not already exist.
-
getOrCreatePackage
- Parameters:
path- the simple name or a relativepathto the requestedCodePackage.- Returns:
- the traversed
CodePackage. Has been created and added if it did not already exist.
-
createPackage
Attention: This method is just a factory operation. It will not add the createdCodePackage. UsegetOrCreatePackage(String)instead to also add.- Parameters:
simpleName- thesimple nameof the newCodePackage.- Returns:
- a new empty
CodePackage.
-
getType
- Parameters:
simpleName- thesimple nameof the requestedCodeType.- Returns:
- the
CodeTypewith the givennameornullif not found.
-
createType
Attention: This method is just a factory operation. It will not add theCodeFileof the createdCodeType. UsegetOrCreateFile(String)instead to also add and then callCodeFile.getType().- Parameters:
simpleName- thesimple nameof the requestedCodeType.- Returns:
- the top-level
CodeTypethat has been created together with itsCodeFile. - See Also:
-
add
Attention: This method is only for advanced usage. Whenever suitable prefer to use methods such asgetOrCreatePackage(CodeName, boolean)orgetOrCreateFile(CodeName, boolean)instead.- Parameters:
child- theCodePathElementto add as child.
-
containsPackage
- Parameters:
child- the potential sub-package.- Returns:
trueif the givenCodePackageis equal to theowning packageor is adirectorindirectsub-packageof thisCodePackage,falseotherwise.
-
containsSubPackage
- Parameters:
child- the potential sub-package.- Returns:
trueif the givenCodePackageis adirectorindirectsub-packageof thisCodePackage,falseotherwise.
-
copy
CodePathElements copy()- Specified by:
copyin interfaceCodeMutableItem- Specified by:
copyin interfaceCodeNodeItem- Specified by:
copyin interfaceCodeNodeItemContainer<CodePathElement>- Specified by:
copyin interfaceCodeNodeItemContainerFlat<CodePathElement>- Specified by:
copyin interfaceCodeNodeItemCopyable<CodePackage, CodePathElements>- Returns:
- a new
mutablecopy of thisCodeMutableItem. Will be a deep-copy with copies of all childCodeMutableItems.
-
copy
- Specified by:
copyin interfaceCodeMutableItem- Specified by:
copyin interfaceCodeNodeItem- Specified by:
copyin interfaceCodeNodeItemContainer<CodePathElement>- Specified by:
copyin interfaceCodeNodeItemCopyable<CodePackage, CodePathElements>- Parameters:
mapper- theCodeCopyMapperused to map involved nodes during copy.- Returns:
- a
CodeMutableItem.copy()with the related objects mapped using the givenCodeCopyMapper.
-