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 Details

  • Constructor Details

  • Method Details

    • doSetImmutable

      protected void doSetImmutable()
      Description copied from class: BaseMutableItem
      Called on the first call of BaseMutableItem.setImmutable(). Has to be overridden to update Collections, make child items immutable, etc.
      Overrides:
      doSetImmutable in class BaseElement
    • getParent

      public io.github.mmm.code.api.node.CodeContainer getParent()
      Specified by:
      getParent in interface io.github.mmm.code.api.node.CodeNode
      Specified by:
      getParent in interface io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.CodePackage>
      Specified by:
      getParent in interface io.github.mmm.code.api.CodePackage
      Specified by:
      getParent in interface io.github.mmm.code.api.CodePathElement
    • getReflectiveObject

      public Package getReflectiveObject()
      Specified by:
      getReflectiveObject in interface io.github.mmm.code.api.item.CodeMutableItem
      Specified by:
      getReflectiveObject in interface io.github.mmm.code.api.CodePackage
      Overrides:
      getReflectiveObject in class BaseMutableItem
    • getSourceCodeObject

      public BasePackage getSourceCodeObject()
      Overrides:
      getSourceCodeObject in class BaseElement
      Returns:
      the optional internal CodeItem representing the source-code (to merge). Otherwise null. This is an internal API. Do not use or rely on it from outside.
    • getContext

      public BaseContext getContext()
      Specified by:
      getContext in interface io.github.mmm.code.api.CodeWithContext
      Overrides:
      getContext in class BaseNodeItem
    • getSource

      public BaseSource getSource()
      Specified by:
      getSource in interface io.github.mmm.code.api.CodeWithContext
      Overrides:
      getSource in class BaseNodeItem
    • isFile

      public boolean isFile()
      Specified by:
      isFile in interface io.github.mmm.code.api.CodePathElement
    • getChildren

      public BasePathElements getChildren()
      Specified by:
      getChildren in interface io.github.mmm.code.api.CodePackage
    • isRequireImport

      public boolean isRequireImport()
      Specified by:
      isRequireImport in interface io.github.mmm.code.api.CodePackage
    • isRoot

      public boolean isRoot()
      Specified by:
      isRoot in interface io.github.mmm.code.api.CodePackage
      Returns:
      true if this is the default package, false otherwise.
    • isJava

      public boolean isJava()
      Returns:
      true if this is the "java" package, false otherwise.
    • isJavaLang

      public boolean isJavaLang()
      Returns:
      true if this is the "java.lang" package (that requires no import), false otherwise.
    • isSystemImmutable

      protected boolean isSystemImmutable()
      Overrides:
      isSystemImmutable in class BaseMutableItem
      Returns:
      true if this is a system internal node item that is considered to be immutable but is technically set to immutable during (lazy) initialization. Otherwise false.
    • copy

      public BasePackage copy()
      Specified by:
      copy in interface io.github.mmm.code.api.element.CodeElement
      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 interface io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.CodePackage>
      Specified by:
      copy in interface io.github.mmm.code.api.CodePackage
    • copy

      public BasePackage copy(io.github.mmm.code.api.copy.CodeCopyMapper mapper)
      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 interface io.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:
      doWrite in class BaseElement
      Parameters:
      sink - the Appendable where to append the code from this CodeItem.
      newline - the newline String.
      defaultIndent - the String used 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 the defaultIndent will be appended.
      language - the CodeLanguage to use.
      Throws:
      IOException - if thrown by Appendable.
      See Also:
      • CodeItem.write(Appendable, String, String)
    • write

      public void write(Path targetFolder)
      Specified by:
      write in interface io.github.mmm.code.api.node.CodeNodeWithFileWriting
    • write

      public void write(Path targetFolder, Charset encoding)
      Specified by:
      write in interface io.github.mmm.code.api.node.CodeNodeWithFileWriting