Interface Marked<N extends Node & Marked<N,​M>,​M extends Mark>

    • Method Detail

      • copy

        N copy()
        Description copied from interface: Element
        Returns 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, a text node that is used inside a codeBlock will 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 this if the element is immutable. The @Immutable annotation 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 parse and toMap methods already have to be updated in these circumstances, so it makes sense to take advantage of that.
        Specified by:
        copy in interface Element
        Specified by:
        copy in interface Node
        Returns:
        a copy of this element, or this if the element is immutable anyway
      • 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 the mark types that have been assigned to this node.
        Returns:
        a set of all the mark types that have been assigned to this node.
      • marks

        <T extends MStream<? 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 markClass is 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 empty if 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 second link mark 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.