Class BasePathElements
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.node.BaseNodeItemContainer<io.github.mmm.code.api.CodePathElement>
io.github.mmm.code.base.node.BaseNodeItemContainerFlat<io.github.mmm.code.api.CodePathElement>
io.github.mmm.code.base.BasePathElements
- All Implemented Interfaces:
io.github.mmm.code.api.CodePathElements, io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodePathElements>, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeContainer<io.github.mmm.code.api.CodePathElement>, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.node.CodeNodeItemContainer<io.github.mmm.code.api.CodePathElement>, io.github.mmm.code.api.node.CodeNodeItemContainerFlat<io.github.mmm.code.api.CodePathElement>, io.github.mmm.code.api.object.CodeMutable, Iterable<io.github.mmm.code.api.CodePathElement>
public class BasePathElements
extends BaseNodeItemContainerFlat<io.github.mmm.code.api.CodePathElement>
implements io.github.mmm.code.api.CodePathElements
Base implementation of
CodePathElements.- 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
ConstructorsConstructorDescriptionBasePathElements(BasePackage parent) The constructor.BasePathElements(BasePathElements template, io.github.mmm.code.api.copy.CodeCopyMapper mapper) The copy-constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(io.github.mmm.code.api.CodePathElement item) protected voidaddInternal(io.github.mmm.code.api.CodePathElement item) booleancontainsPackage(io.github.mmm.code.api.CodePackage child) booleancontainsSubPackage(io.github.mmm.code.api.CodePackage child) copy()copy(io.github.mmm.code.api.copy.CodeCopyMapper mapper) createFile(String simpleName) createPackage(String simpleName) createType(String simpleName) protected voiddoWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) protected io.github.mmm.code.api.CodePathElementensureParent(io.github.mmm.code.api.CodePathElement item) io.github.mmm.code.api.CodePathElementgetFile(io.github.mmm.code.api.CodeName path) getOrCreateFile(io.github.mmm.code.api.CodeName path, boolean add) getOrCreateFile(io.github.mmm.code.api.CodeName path, boolean add, boolean init) protected BaseFilegetOrCreateFile(io.github.mmm.code.api.CodeName path, boolean add, boolean init, boolean forceAdd) getOrCreatePackage(io.github.mmm.code.api.CodeName path, boolean add) getOrCreatePackage(io.github.mmm.code.api.CodeName path, boolean add, boolean init) protected BasePackagegetOrCreatePackage(io.github.mmm.code.api.CodeName path, boolean add, boolean init, boolean forceAdd) getPackage(io.github.mmm.code.api.CodeName path) getPackage(io.github.mmm.code.api.CodeName path, boolean init) getPackage(io.github.mmm.code.api.CodeName path, boolean init, BiFunction<BasePackage, String, BasePackage> factory, boolean add) protected BasePackagegetPackage(io.github.mmm.code.api.CodeName path, boolean init, BiFunction<BasePackage, String, BasePackage> factory, boolean add, boolean forceAdd) Attention: This is an internal API that should not be used from outside.getPackage(String simpleName) getPackage(String simpleName, boolean init) io.github.mmm.code.api.type.CodeTypeio.github.mmm.code.api.type.CodeTypeprotected booleanprotected booleanisNamed()toString()Methods inherited from class BaseNodeItemContainer
clear, doSetImmutable, getByName, getDeclared, getItemCopyType, getKey, getList, getMap, isSystemImmutable, remove, renameMethods inherited from class BaseNodeItem
doInitialize, getContainerItem, getContainerItemDeclared, getContext, getLanguage, getSource, toPathStringMethods inherited from class BaseMutableItem
doCopyNode, doCopyNodeUnsafe, doMapList, doneInitialize, getDefaultCopyMapper, getDefaultEncoding, getReflectiveObject, getSourceCodeObject, initialize, initialize, isImmutable, isInitialized, isInitializing, isSystemImmutable, makeImmutable, makeImmutable, setImmutable, setImmutableIfNotSystemImmutable, verifyMutalbe, writeItemMethods inherited from class BaseItem
getOwningType, getSourceCode, getSpaces, writeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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.object.CodeMutable
isImmutable, isMutableMethods inherited from interface io.github.mmm.code.api.item.CodeMutableItem
getReflectiveObject, setImmutableMethods inherited from interface io.github.mmm.code.api.node.CodeNodeContainer
isEmpty, iteratorMethods inherited from interface io.github.mmm.code.api.node.CodeNodeItemContainer
removeMethods inherited from interface io.github.mmm.code.api.CodePathElements
getDeclared, getOrCreateFile, getOrCreatePackageMethods inherited from interface io.github.mmm.code.api.CodeWithContext
getContext, getSourceMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
BasePathElements
-
BasePathElements
public BasePathElements(BasePathElements template, io.github.mmm.code.api.copy.CodeCopyMapper mapper) The copy-constructor.- Parameters:
template- theBasePathElementsto copy.mapper- theCodeCopyMapper.
-
-
Method Details
-
isKeepListView
protected boolean isKeepListView()- Overrides:
isKeepListViewin classBaseNodeItemContainer<io.github.mmm.code.api.CodePathElement>- Returns:
trueif theListshould turn into an immutable view on the original mutableList,falseotherwise.- See Also:
-
isNamed
protected boolean isNamed()- Overrides:
isNamedin classBaseNodeItemContainer<io.github.mmm.code.api.CodePathElement>- Returns:
trueif this is a named container that requires amap,falseotherwise.
-
getParent
- Specified by:
getParentin interfaceio.github.mmm.code.api.node.CodeNode- Specified by:
getParentin interfaceio.github.mmm.code.api.node.CodeNodeItemContainer<io.github.mmm.code.api.CodePathElement>- Specified by:
getParentin interfaceio.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodePathElements>- Specified by:
getParentin interfaceio.github.mmm.code.api.CodePathElements
-
get
- Specified by:
getin interfaceio.github.mmm.code.api.CodePathElements
-
getFile
-
getFile
- Parameters:
simpleName- thesimple nameof the requestedCodeFile.init- -truetoinitialize,falseotherwise.- Returns:
- the
CodeFilewith the givennameornullif not found.
-
getFile
- Specified by:
getFilein interfaceio.github.mmm.code.api.CodePathElements
-
add
public void add(io.github.mmm.code.api.CodePathElement item) - Specified by:
addin interfaceio.github.mmm.code.api.CodePathElements- Overrides:
addin classBaseNodeItemContainer<io.github.mmm.code.api.CodePathElement>- Parameters:
item- the item to add.
-
addInternal
protected void addInternal(io.github.mmm.code.api.CodePathElement item) - Overrides:
addInternalin classBaseNodeItemContainer<io.github.mmm.code.api.CodePathElement>- Parameters:
item- the item to add.
-
ensureParent
protected io.github.mmm.code.api.CodePathElement ensureParent(io.github.mmm.code.api.CodePathElement item) - Overrides:
ensureParentin classBaseNodeItemContainer<io.github.mmm.code.api.CodePathElement>- Parameters:
item- the item toadd.- Returns:
- the item itself or a
copywith this container as parent.
-
getPackage
- Specified by:
getPackagein interfaceio.github.mmm.code.api.CodePathElements
-
getPackage
- Parameters:
simpleName- thesimple nameof the requestedCodePackage.init- -truetoinitialize,falseotherwise.- Returns:
- the
BasePackagewith the givennameornullif not found.
-
getPackage
- Specified by:
getPackagein interfaceio.github.mmm.code.api.CodePathElements
-
getPackage
- Parameters:
path- theCodeNameleading to the requested child. SeegetPackage(CodeName, boolean).init- -truetoinitialize,falseotherwise.- Returns:
- the traversed
BasePackageornullif not found.
-
getPackage
public BasePackage getPackage(io.github.mmm.code.api.CodeName path, boolean init, BiFunction<BasePackage, String, BasePackage> factory, boolean add) - Parameters:
path- theCodeNameleading to the requested child. SeegetPackage(CodeName, boolean).init- -truetoinitialize,falseotherwise.factory- theBiFunctionused as factory to create missing packages.add- -truetoaddnew packages created by the givenfactory,falseotherwise.- Returns:
- the traversed
BasePackage. Has been created if it did not already exist and was produced by the givenfactory.
-
getPackage
protected BasePackage getPackage(io.github.mmm.code.api.CodeName path, boolean init, BiFunction<BasePackage, String, BasePackage> factory, boolean add, boolean forceAdd) Attention: This is an internal API that should not be used from outside. UsegetPackage(CodeName, boolean, BiFunction, boolean)instead.- Parameters:
path- theCodeNameto traverse.init- -truetoinitialize,falseotherwise.factory- theBiFunctionused as factory to create missing packages.add- -truetoaddnew packages created by the givenfactory,falseotherwise.forceAdd- -trueto force adding (ifaddistruebutis immutable),falseotherwise.- Returns:
- the traversed
BasePackage. Has been created if it did not already exist and was produced by the givenfactory.
-
getOrCreatePackage
- Specified by:
getOrCreatePackagein interfaceio.github.mmm.code.api.CodePathElements
-
getOrCreatePackage
public BasePackage getOrCreatePackage(io.github.mmm.code.api.CodeName path, boolean add, boolean init) - Parameters:
path- theCodeNameleading to the requested child. SeegetOrCreatePackage(CodeName, boolean).add- -truetoaddnewly created packages,falseotherwise.init- -truetoinitialize,falseotherwise.- Returns:
- the traversed
BasePackage. Has been created if it did not already exist.
-
getOrCreatePackage
protected BasePackage getOrCreatePackage(io.github.mmm.code.api.CodeName path, boolean add, boolean init, boolean forceAdd) - Parameters:
path- theCodeNameleading to the requested child. SeegetOrCreatePackage(CodeName, boolean).add- -truetoaddnewly created packages,falseotherwise.init- -truetoinitialize,falseotherwise.forceAdd- -trueto force adding (ifaddistruebutis immutable),falseotherwise.- Returns:
- the traversed
BasePackage. Has been created if it did not already exist.
-
createPackage
- Specified by:
createPackagein interfaceio.github.mmm.code.api.CodePathElements
-
getOrCreateFile
- Specified by:
getOrCreateFilein interfaceio.github.mmm.code.api.CodePathElements
-
getOrCreateFile
- Parameters:
path- theCodeNameleading to the requested child. SeegetOrCreateFile(CodeName, boolean).add- -trueto add a newly createdCodeFile,falseotherwise.init- -truetoinitialize,falseotherwise.- Returns:
- the
existingornewly createdCodeFile.
-
getOrCreateFile
protected BaseFile getOrCreateFile(io.github.mmm.code.api.CodeName path, boolean add, boolean init, boolean forceAdd) - Parameters:
path- theCodeNameleading to the requested child. SeegetOrCreateFile(CodeName, boolean).add- -trueto add a newly createdCodeFile,falseotherwise.init- -truetoinitialize,falseotherwise.forceAdd- -trueto force adding (ifaddistruebutis immutable),falseotherwise.- Returns:
- the
existingornewly createdCodeFile.
-
createFile
-
getType
- Specified by:
getTypein interfaceio.github.mmm.code.api.CodePathElements
-
getType
- Parameters:
simpleName- thesimple nameof the requestedCodeType.init- -truetoinitialize,falseotherwise.- Returns:
- the
CodeTypewith the givennameornullif not found.
-
createType
-
containsPackage
public boolean containsPackage(io.github.mmm.code.api.CodePackage child) - Specified by:
containsPackagein interfaceio.github.mmm.code.api.CodePathElements
-
containsSubPackage
public boolean containsSubPackage(io.github.mmm.code.api.CodePackage child) - Specified by:
containsSubPackagein interfaceio.github.mmm.code.api.CodePathElements
-
copy
- Specified by:
copyin interfaceio.github.mmm.code.api.item.CodeMutableItem- Specified by:
copyin interfaceio.github.mmm.code.api.node.CodeNodeItem- Specified by:
copyin interfaceio.github.mmm.code.api.node.CodeNodeItemContainer<io.github.mmm.code.api.CodePathElement>- Specified by:
copyin interfaceio.github.mmm.code.api.node.CodeNodeItemContainerFlat<io.github.mmm.code.api.CodePathElement>- Specified by:
copyin interfaceio.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodePathElements>- Specified by:
copyin interfaceio.github.mmm.code.api.CodePathElements
-
copy
- Specified by:
copyin interfaceio.github.mmm.code.api.item.CodeMutableItem- Specified by:
copyin interfaceio.github.mmm.code.api.node.CodeNodeItem- Specified by:
copyin interfaceio.github.mmm.code.api.node.CodeNodeItemContainer<io.github.mmm.code.api.CodePathElement>- Specified by:
copyin interfaceio.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodePathElements>- Specified by:
copyin interfaceio.github.mmm.code.api.CodePathElements
-
doWrite
protected void doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) throws IOException - Specified by:
doWritein classBaseItem- Parameters:
sink- theAppendablewhere toappendthe code from thisCodeItem.newline- the newlineString.defaultIndent- theStringused for indentation (e.g. a number of spaces to insert per indent level).currentIndent- the current indent (number of spaces). Initially the empty string (""). Before a recursion thedefaultIndentwill be appended.language- theCodeLanguageto use.- Throws:
IOException- if thrown byAppendable.- See Also:
-
toString
-