Class BasePackage
- All Implemented Interfaces:
io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodePathElement, io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.CodePackage>, io.github.mmm.code.api.element.CodeElement, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeItemWithComment, io.github.mmm.code.api.item.CodeItemWithQualifiedName, io.github.mmm.code.api.item.CodeItemWithQualifiedNameAndParentPackage, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.item.CodeMutableItemWithComment, io.github.mmm.code.api.item.CodeMutableItemWithQualifiedName, io.github.mmm.code.api.node.CodeContainer, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.node.CodeNodeWithFileWriting, io.github.mmm.code.api.object.CodeMutable
public final class BasePackage
extends BasePathElement
implements io.github.mmm.code.api.CodePackage
Base implementation of
CodePackage.- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSimple nameof the default (root) package.static final StringSimple name"java".static final StringSimple name"lang".static final StringSimple name"util".Fields inherited from interface io.github.mmm.code.api.item.CodeItem
DEFAULT_INDENT, DEFAULT_NEWLINE -
Constructor Summary
ConstructorsConstructorDescriptionBasePackage(BasePackage template, io.github.mmm.code.api.copy.CodeCopyMapper mapper) The copy-constructor.BasePackage(BasePackage parentPackage, String simpleName) The constructor.BasePackage(BasePackage parentPackage, String simpleName, Package reflectiveObject, Supplier<BasePackage> sourceSupplier, boolean systemImmutable) The constructor.BasePackage(BaseSource source) The constructor for arootpackage. -
Method Summary
Modifier and TypeMethodDescriptioncopy()copy(io.github.mmm.code.api.copy.CodeCopyMapper mapper) protected voidCalled on the first call ofBaseMutableItem.setImmutable().protected voiddoWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) io.github.mmm.code.api.node.CodeContainerbooleanisFile()booleanisJava()booleanbooleanbooleanisRoot()protected booleanvoidvoidMethods inherited from class BasePathElement
doSetParentPackage, removeFromParentMethods inherited from class BaseElementWithQualifiedName
getParentPackage, getQualifiedName, getSimpleName, setParentPackage, setSimpleNameMethods inherited from class BaseElement
doInitialize, doMerge, doWriteAnnotations, doWriteComment, doWriteDoc, getAnnotations, getComment, getDoc, setCommentMethods inherited from class BaseNodeItem
getContainerItem, getContainerItemDeclared, getLanguage, toPathStringMethods inherited from class BaseMutableItem
doCopyNode, doCopyNodeUnsafe, doMapList, doneInitialize, getDefaultCopyMapper, getDefaultEncoding, initialize, initialize, isImmutable, isInitialized, isInitializing, isSystemImmutable, makeImmutable, makeImmutable, setImmutable, setImmutableIfNotSystemImmutable, verifyMutalbe, writeItemMethods inherited from class 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
getAnnotations, getDoc, removeFromParentMethods 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.CodeItemWithComment
getCommentMethods inherited from interface io.github.mmm.code.api.item.CodeItemWithQualifiedName
getSimpleNameMethods inherited from interface io.github.mmm.code.api.item.CodeItemWithQualifiedNameAndParentPackage
getParentPackage, getQualifiedNameMethods 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
setComment
-
Field Details
-
NAME_DEFAULT
-
NAME_JAVA
-
NAME_LANG
-
NAME_UTIL
-
-
Constructor Details
-
BasePackage
-
BasePackage
The constructor.- Parameters:
parentPackage- theparent package.simpleName- thesimple name.
-
BasePackage
public BasePackage(BasePackage parentPackage, String simpleName, Package reflectiveObject, Supplier<BasePackage> sourceSupplier, boolean systemImmutable) The constructor.- Parameters:
parentPackage- theparent package.simpleName- thesimple name.reflectiveObject- thereflective object.sourceSupplier- the optionalSupplierfor lazy-loading of source-code.systemImmutable- thesystem immutable flag.
-
BasePackage
The copy-constructor.- Parameters:
template- theBasePackageto copy.mapper- theCodeCopyMapper.
-
-
Method Details
-
doSetImmutable
protected void doSetImmutable()Description copied from class:BaseMutableItemCalled on the first call ofBaseMutableItem.setImmutable(). Has to be overridden to updateCollections, make child items immutable, etc.- Overrides:
doSetImmutablein classBaseElement
-
getParent
public io.github.mmm.code.api.node.CodeContainer getParent()- Specified by:
getParentin interfaceio.github.mmm.code.api.node.CodeNode- Specified by:
getParentin interfaceio.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.CodePackage>- Specified by:
getParentin interfaceio.github.mmm.code.api.CodePackage- Specified by:
getParentin interfaceio.github.mmm.code.api.CodePathElement
-
getReflectiveObject
- Specified by:
getReflectiveObjectin interfaceio.github.mmm.code.api.item.CodeMutableItem- Specified by:
getReflectiveObjectin interfaceio.github.mmm.code.api.CodePackage- Overrides:
getReflectiveObjectin classBaseMutableItem
-
getSourceCodeObject
- Overrides:
getSourceCodeObjectin classBaseElement- Returns:
- the optional internal
CodeItemrepresenting the source-code (to merge). Otherwisenull. This is an internal API. Do not use or rely on it from outside.
-
getContext
- Specified by:
getContextin interfaceio.github.mmm.code.api.CodeWithContext- Overrides:
getContextin classBaseNodeItem
-
getSource
- Specified by:
getSourcein interfaceio.github.mmm.code.api.CodeWithContext- Overrides:
getSourcein classBaseNodeItem
-
isFile
public boolean isFile()- Specified by:
isFilein interfaceio.github.mmm.code.api.CodePathElement
-
getChildren
- Specified by:
getChildrenin interfaceio.github.mmm.code.api.CodePackage
-
isRequireImport
public boolean isRequireImport()- Specified by:
isRequireImportin interfaceio.github.mmm.code.api.CodePackage
-
isRoot
public boolean isRoot()- Specified by:
isRootin interfaceio.github.mmm.code.api.CodePackage- Returns:
trueif this is the default package,falseotherwise.
-
isJava
public boolean isJava()- Returns:
trueif this is the "java" package,falseotherwise.
-
isJavaLang
public boolean isJavaLang()- Returns:
trueif this is the "java.lang" package (that requires no import),falseotherwise.
-
isSystemImmutable
protected boolean isSystemImmutable()- Overrides:
isSystemImmutablein classBaseMutableItem- Returns:
trueif this is a system internal node item that is considered to beimmutablebut is technicallyset to immutableduring (lazy)initialization. Otherwisefalse.
-
copy
- Specified by:
copyin interfaceio.github.mmm.code.api.element.CodeElement- 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.copy.CodeNodeItemCopyable<io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.CodePackage>- Specified by:
copyin interfaceio.github.mmm.code.api.CodePackage
-
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.copy.CodeNodeItemCopyable<io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.CodePackage>
-
doWrite
protected void doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) throws IOException - Overrides:
doWritein classBaseElement- 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:
-
write
- Specified by:
writein interfaceio.github.mmm.code.api.node.CodeNodeWithFileWriting
-
write
-