Class BaseMutableItem
java.lang.Object
io.github.mmm.code.base.item.BaseItem
io.github.mmm.code.base.item.BaseMutableItem
- All Implemented Interfaces:
io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.object.CodeMutable
- Direct Known Subclasses:
BaseNodeItem
public abstract class BaseMutableItem
extends BaseItem
implements io.github.mmm.code.api.item.CodeMutableItem
Base implementation of
CodeMutableItem.- 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
ConstructorsConstructorDescriptionThe constructor.BaseMutableItem(BaseMutableItem template) The copy-constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected <P extends io.github.mmm.code.api.node.CodeNodeItem, N extends io.github.mmm.code.api.copy.CodeNodeItemCopyable<P,N>>
NdoCopyNode(N node, P parent) protected <N extends io.github.mmm.code.api.node.CodeNodeItem>
NdoCopyNodeUnsafe(N node, io.github.mmm.code.api.node.CodeNodeItem parent) protected voidCalled frominitialize()on first invocation.protected <N extends io.github.mmm.code.api.node.CodeNode>
List<N> doMapList(List<N> list, io.github.mmm.code.api.copy.CodeCopyMapper mapper, io.github.mmm.code.api.copy.CodeCopyType type) protected voidCalled frominitialize()on first invocation afterdoInitialize()is complete.protected voidCalled on the first call ofsetImmutable().protected io.github.mmm.code.api.copy.CodeCopyMapperprotected static Charsetio.github.mmm.code.api.item.CodeItemprotected final voidInitializes this node item.protected final voidinitialize(boolean init) booleanprotected final booleanprotected final booleanprotected booleanprotected static booleanprotected <T extends io.github.mmm.code.api.item.CodeItem>
List<T> makeImmutable(List<T> list) protected <T extends io.github.mmm.code.api.item.CodeItem>
List<T> makeImmutable(List<T> list, boolean disconnect) voidMakes this itemimmutable.voidCallssetImmutable()but only if notsystem immutable.protected voidVerifies that this item is notimmutable.protected voidwriteItem(io.github.mmm.code.api.item.CodeItem item, Path targetFolder, String filename, Charset encoding) Methods inherited from class BaseItem
doWrite, 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.item.CodeItem
getLanguage, getSourceCode, write, write, write, write, write, writeMethods inherited from interface io.github.mmm.code.api.object.CodeMutable
isMutableMethods inherited from interface io.github.mmm.code.api.item.CodeMutableItem
copy, copy
-
Constructor Details
-
BaseMutableItem
public BaseMutableItem()The constructor. -
BaseMutableItem
The copy-constructor.- Parameters:
template- theBaseMutableItemto copy.
-
-
Method Details
-
initialize
protected final void initialize()Initializes this node item. -
isInitializing
protected final boolean isInitializing()- Returns:
trueif theinitializationof this item has started but is not yetcomplete,falseotherwise.
-
isInitialized
protected final boolean isInitialized()- Returns:
trueif theinitializationof this item has been completed,falseotherwise.
-
doInitialize
protected void doInitialize()Called frominitialize()on first invocation. May be overridden but never be called from anywhere else. -
doneInitialize
protected void doneInitialize()Called frominitialize()on first invocation afterdoInitialize()is complete. May be overridden but never be called from anywhere else. -
initialize
protected final void initialize(boolean init) - Parameters:
init-trueto callinitialize(),falseto do nothing.
-
isImmutable
public boolean isImmutable()- Specified by:
isImmutablein interfaceio.github.mmm.code.api.object.CodeMutable
-
getReflectiveObject
- Specified by:
getReflectiveObjectin interfaceio.github.mmm.code.api.item.CodeMutableItem
-
getSourceCodeObject
public io.github.mmm.code.api.item.CodeItem getSourceCodeObject()- 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.
-
isSystemImmutable
protected boolean isSystemImmutable()- Returns:
trueif this is a system internal node item that is considered to beimmutablebut is technicallyset to immutableduring (lazy)initialization. Otherwisefalse.
-
isSystemImmutable
- Parameters:
item- theBaseMutableItem.- Returns:
- the result of
isSystemImmutable().
-
setImmutableIfNotSystemImmutable
public void setImmutableIfNotSystemImmutable()CallssetImmutable()but only if notsystem immutable. Use this method for implementations ofdoSetImmutable()to propagate immutable-flag to children in order to prevent eager initialization. -
setImmutable
public void setImmutable()Makes this itemimmutable.- Specified by:
setImmutablein interfaceio.github.mmm.code.api.item.CodeMutableItem
-
doSetImmutable
protected void doSetImmutable()Called on the first call ofsetImmutable(). Has to be overridden to updateCollections, make child items immutable, etc. -
verifyMutalbe
protected void verifyMutalbe()Verifies that this item is notimmutable. Call this method from any edit-method (setter, etc.).- Throws:
io.github.mmm.base.exception.ReadOnlyException- if this item is immutable.
-
makeImmutable
-
makeImmutable
-
getDefaultCopyMapper
protected io.github.mmm.code.api.copy.CodeCopyMapper getDefaultCopyMapper()- Returns:
- the default implementation of
CodeCopyMapper.
-
doMapList
-
doCopyNodeUnsafe
protected <N extends io.github.mmm.code.api.node.CodeNodeItem> N doCopyNodeUnsafe(N node, io.github.mmm.code.api.node.CodeNodeItem parent) - Type Parameters:
N- type of theCodeNodeItemto copy.- Parameters:
node- theCodeNodeItemto copy.parent- the newparent.- Returns:
- the copy.
-
doCopyNode
protected <P extends io.github.mmm.code.api.node.CodeNodeItem, N extends io.github.mmm.code.api.copy.CodeNodeItemCopyable<P,N>> N doCopyNode(N node, P parent) - Type Parameters:
P- type of theparent.N- type of theCodeNodeItemto copy.- Parameters:
node- theCodeNodeItemto copy.parent- the newparent.- Returns:
- the copy.
-
writeItem
-
getDefaultEncoding
-