Class AbstractMarkedNode<N extends AbstractMarkedNode<N,M>,M extends Mark>
- java.lang.Object
-
- com.atlassian.adf.model.node.AbstractNode<N>
-
- com.atlassian.adf.model.node.AbstractMarkedNode<N,M>
-
- Direct Known Subclasses:
Extension,InlineExtension,MediaInline,MediaSingle,Text
@Internal public abstract class AbstractMarkedNode<N extends AbstractMarkedNode<N,M>,M extends Mark> extends AbstractNode<N> implements Marked<N,M>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.atlassian.adf.model.node.AbstractNode
AbstractNode.ToStringHelper
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidappendMarkedNodeFields(AbstractNode.ToStringHelper buf)protected voidappendNodeFields(AbstractNode.ToStringHelper buf)Allows nodes that have their own fields to augment thetoString()implementation with their own field values.abstract Ncopy()Returns a deep copy of this element, including copies of any nodes or marks that it contains.protected com.atlassian.adf.model.node.MarkHolder<M>createMarkHolder()Optional<M>mark(String type)Returns the existing mark of the given type, if it exists.Nmark(M mark)Adds the given mark to this marked node.abstract Class<M>markClass()Returns the type of marks that may be applied to this node.protected booleanmarkedNodeEquals(N other)protected intmarkedNodeHashCode()protected voidmarkedNodeValidate()Collection<M>marks()Returns a list of the marks currently assigned to this node.<T extends M>
Stream<? extends T>marks(Class<T> markClass)Returns a stream of the marks that are currently assigned to this node and match the given type.Set<String>markTypes()Returns a set of all themark typesthat have been assigned to this node.protected booleannodeEquals(N other)Allows nodes that have their own fields to augment theequalsimplementation with tests for their own field values.protected intnodeHashCode()Allows nodes that have their own fields to augment thehashCodeimplementation with a hash of their own field values.protected NparseMarks(Map<String,?> map)protected Factory<M>unsupportedMarkFactory()voidvalidate()Verifies that the node is well-formed (including the state of any descendents that it has).-
Methods inherited from class com.atlassian.adf.model.node.AbstractNode
appendPlainText, doubleEq, doubleHash, equals, hashCode, isSupported, mapWithType, numberEq, numberHash, self, toPlainText, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.atlassian.adf.model.Element
elementType, isSupported, toMap
-
Methods inherited from interface com.atlassian.adf.model.node.Node
appendPlainText, toPlainText
-
-
-
-
Method Detail
-
validate
public final void validate()
Description copied from interface:ElementVerifies that the node is well-formed (including the state of any descendents that it has).
-
markedNodeValidate
protected void markedNodeValidate()
-
copy
public abstract N copy()
Description copied from interface:ElementReturns a deep copy of this element, including copies of any nodes or marks that it contains. The copy will not necessarily be in exactly the same state as the original in some cases. For example, atextnode that is used inside acodeBlockwill have the ability to use marks on it disabled, but a copy made of the text node using this method will not similarly disallow marks unless it is also added to a content node with those same restrictions.Implementations notes:
- Implementations should narrow the return type.
- Implementations should
return thisif the element is immutable. The@Immutableannotation should be used on the class to offer additional confirmation of this intent. - Implementations should
return parse(toMap())if they have state. - While there may be cases where it is worthwhile to do something more efficient than
the conversion to a map and back, this is discouraged because it would add yet another
fragile piece of code that breaks when new data is added to the node. The
parseandtoMapmethods already have to be updated in these circumstances, so it makes sense to take advantage of that.
-
markClass
public abstract Class<M> markClass()
Description copied from interface:MarkedReturns the type of marks that may be applied to this node.
-
createMarkHolder
protected com.atlassian.adf.model.node.MarkHolder<M> createMarkHolder()
-
marks
public final Collection<M> marks()
Description copied from interface:MarkedReturns a list of the marks currently assigned to this node.
-
markTypes
public final Set<String> markTypes()
Description copied from interface:MarkedReturns a set of all themark typesthat have been assigned to this node.- Specified by:
markTypesin interfaceMarked<N extends AbstractMarkedNode<N,M>,M extends Mark>- Returns:
- a set of all the
mark typesthat have been assigned to this node.
-
marks
public final <T extends M> Stream<? extends T> marks(Class<T> markClass)
Description copied from interface:MarkedReturns a stream of the marks that are currently assigned to this node and match the given type.Since only one mark of each type is permitted to be assigned to a single node, the stream will not contain multiple elements when
markClassis a concrete mark class.
-
mark
public final Optional<M> mark(String type)
Description copied from interface:MarkedReturns the existing mark of the given type, if it exists.
-
mark
public N mark(M mark)
Description copied from interface:MarkedAdds the given mark to this marked node.
-
markedNodeHashCode
protected int markedNodeHashCode()
-
markedNodeEquals
protected boolean markedNodeEquals(N other)
-
appendMarkedNodeFields
protected void appendMarkedNodeFields(AbstractNode.ToStringHelper buf)
-
nodeHashCode
protected final int nodeHashCode()
Description copied from class:AbstractNodeAllows nodes that have their own fields to augment thehashCodeimplementation with a hash of their own field values.Implementations need not include the node's class; that is already covered by the
AbstractNode.hashCode()implementation that is expected to be this method's only consumer.Just as with the relationship between
hashCode,equals, andtoStringfor ordinary Java classes, subclasses ofAbstractNodeshould maintain consistent implementations ofnodeHashCode,nodeEquals, andappendNodeFields.- Overrides:
nodeHashCodein classAbstractNode<N extends AbstractMarkedNode<N,M>>- Returns:
- the hash code of any additional field values that belong to a particular type of content node.
- See Also:
AbstractNode.nodeEquals(AbstractNode),AbstractNode.appendNodeFields(ToStringHelper)
-
nodeEquals
protected final boolean nodeEquals(N other)
Description copied from class:AbstractNodeAllows nodes that have their own fields to augment theequalsimplementation with tests for their own field values.Implementations need not check for identity,
null, or a different node class; those are already covered by theAbstractNode.equals(Object)implementation that is expected to be this method's only consumer.Just as with the relationship between
hashCode,equals, andtoStringfor ordinary Java classes, subclasses ofAbstractNodeshould maintain consistent implementations ofnodeHashCode,nodeEquals, andappendNodeFields.- Overrides:
nodeEqualsin classAbstractNode<N extends AbstractMarkedNode<N,M>>- Returns:
trueif all additional field values that belong to a particular type of content node test as equal;falseif differences are found- See Also:
AbstractNode.nodeHashCode(),AbstractNode.appendNodeFields(ToStringHelper)
-
appendNodeFields
protected final void appendNodeFields(AbstractNode.ToStringHelper buf)
Description copied from class:AbstractNodeAllows nodes that have their own fields to augment thetoString()implementation with their own field values.Each field's value should be provided by calling
AbstractNode.ToStringHelper.appendField(String, Object). Thevaluemay benull, in which case the field is omitted, for brevity. It will handle array values gracefully, including arrays of primitive types.Just as with the relationship between
hashCode,equals, andtoStringfor ordinary Java classes, subclasses ofAbstractNodeshould maintain consistent implementations ofnodeHashCode,nodeEquals, andappendNodeFields.- Overrides:
appendNodeFieldsin classAbstractNode<N extends AbstractMarkedNode<N,M>>- Parameters:
buf- where the field values should be written- See Also:
AbstractNode.nodeHashCode(),AbstractNode.nodeEquals(AbstractNode)
-
-