Interface Element

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Element copy()
      Returns a deep copy of this element, including copies of any nodes or marks that it contains.
      String elementType()
      The type value that identifies this element, such as "paragraph" or "strong".
      boolean isSupported()
      Indicates whether this element is fully supported by this library.
      static String nonEmpty​(String value, String propertyName)
      A convenience method used during parsing to throw a MissingProperty exception for missing required values or EmptyProperty exception if the value provided is an empty string.
      static <T> T nonNull​(T value, String propertyName)
      A convenience method used during parsing to throw a MissingProperty exception for missing required values.
      static String nullOrNonEmpty​(String value, String propertyName)
      A convenience method used during parsing to throw an EmptyProperty exception if the value provided is an empty string, while still permitting null.
      Map<String,​?> toMap()
      Transforms this element to a map of String values to various basic object types suitable for direct rendering as JSON content.
      void validate()
      Verifies that the node is well-formed (including the state of any descendents that it has).
    • Method Detail

      • elementType

        String elementType()
        The type value that identifies this element, such as "paragraph" or "strong".
      • toMap

        Map<String,​?> toMap()
        Transforms this element to a map of String values to various basic object types suitable for direct rendering as JSON content.
        Returns:
        the map representation of this ADF element
        Throws:
        AdfException - if the element is not in a valid state. The most likely cause for this is a content node (such as a listItem) that is not permitted to be empty. For content nodes, the descendants are included in the generated map, so their states are also validated.
      • copy

        Element copy()
        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.
        Returns:
        a copy of this element, or this if the element is immutable anyway
        Throws:
        AdfException - as for toMap()
      • isSupported

        boolean isSupported()
        Indicates whether this element is fully supported by this library. This library includes a small amount of support for preserving new, unrecognized node types during a round trip. These are represented by immutable placeholder objects that return false for this value.
        Returns:
        true for fully supported elements; false for immutable placeholders
      • validate

        void validate()
        Verifies that the node is well-formed (including the state of any descendents that it has).
        Throws:
        IllegalStateException - if the node does not currently represent valid ADF content
      • nonNull

        static <T> T nonNull​(@Nullable
                             T value,
                             String propertyName)
        A convenience method used during parsing to throw a MissingProperty exception for missing required values.
        Type Parameters:
        T - the inferred type of value
        Parameters:
        value - the value to check
        propertyName - the name of the property that the value was read from
        Returns:
        value, which has been verified as non-null
        Throws:
        AdfException.MissingProperty - if value is null
      • nullOrNonEmpty

        @Nullable
        static String nullOrNonEmpty​(@Nullable
                                     String value,
                                     String propertyName)
        A convenience method used during parsing to throw an EmptyProperty exception if the value provided is an empty string, while still permitting null.
        Parameters:
        value - the value to check
        propertyName - the name of the property that the value was read from
        Returns:
        value, which may be null, but will not be ""
        Throws:
        AdfException.EmptyProperty - if value is ""
      • nonEmpty

        static String nonEmpty​(String value,
                               String propertyName)
        A convenience method used during parsing to throw a MissingProperty exception for missing required values or EmptyProperty exception if the value provided is an empty string.
        Parameters:
        value - the value to check
        propertyName - the name of the property that the value was read from
        Returns:
        value, which has been verified as non-null
        Throws:
        AdfException.MissingProperty - if value is null
        AdfException.EmptyProperty - if value is ""