-
- Type Parameters:
M- the type of marks that this node is able to use
- All Known Subinterfaces:
ExtensionNode<N,M>,Media
- All Known Implementing Classes:
AbstractMarkedContentNode,AbstractMarkedNode,BodiedExtension,CodeBlock,Expand,Extension,Heading,InlineExtension,LayoutSection,Media.AbstractMedia,Media.ExternalMedia,Media.FileMedia,Media.FileOrLinkMedia,Media.LinkMedia,MediaInline,MediaSingle,Paragraph,Table,Text
public interface Marked<N extends Node & Marked<N,M>,M extends Mark> extends Node
Indicates that this node can use amarkselement to alter its presentation.The use of marks is often restricted depending on the surrounding context. For example, the
textnodes within acodeBlockare not allowed to use marks at all.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Ncopy()Returns a deep copy of this element, including copies of any nodes or marks that it contains.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.Class<M>markClass()Returns the type of marks that may be applied to this node.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.-
Methods inherited from interface com.atlassian.adf.model.Element
elementType, isSupported, toMap, validate
-
Methods inherited from interface com.atlassian.adf.model.node.Node
appendPlainText, toPlainText
-
-
-
-
Method Detail
-
copy
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
Class<M> markClass()
Returns the type of marks that may be applied to this node.- Returns:
- the type of marks that may be applied to this node, which is the concrete type for the generic
type
<M>on this interface.
-
marks
Collection<M> marks()
Returns a list of the marks currently assigned to this node.- Returns:
- a list of the marks currently assigned to this node.
-
markTypes
Set<String> markTypes()
Returns a set of all themark typesthat have been assigned to this node.- Returns:
- a set of all the
mark typesthat have been assigned to this node.
-
marks
<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.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.- Type Parameters:
T- the inferred mark class- Parameters:
markClass- the mark types to be included in the stream- Returns:
- the stream of matching marks
-
mark
Optional<M> mark(String type)
Returns the existing mark of the given type, if it exists.- Parameters:
type- the mark type to look up- Returns:
- the existing mark, or
emptyif no such mark does exist
-
mark
N mark(M mark)
Adds the given mark to this marked node.- Parameters:
mark- the mark to be added- Returns:
this- Throws:
IllegalArgumentException- if the mark cannot be added because it conflicts with an existing mark, such as trying to add a secondlinkmark to the same piece of text.IllegalStateException- if the mark cannot be added because marks are disabled or otherwise restricted in the node's current context.
-
-