Package com.atlassian.adf.model
Interface Element
-
- All Known Subinterfaces:
BodiedExtensionMark,CaptionContent,CodeBlockMark,CodeTextMark,ContentNode<C,N>,DocContent,ExpandMark,ExtensionMark,ExtensionNode<N,M>,FormattedTextMark,HeadingMark,InlineContent,InlineExtensionMark,InternalMediaNode,LayoutColumnContent,LayoutSectionMark,ListItemContent,ListNode<L>,Mark,Marked<N,M>,Media,MediaInlineMark,MediaMark,MediaSingleMark,NestedExpandContent,Node,NonNestableBlockContent,PanelContent,ParagraphMark,PositionMark,TableCellContent,TableCellNode<N>,TableMark,TableRowContent,TaskListContent,TextMark
- All Known Implementing Classes:
AbstractContentNode,AbstractListNode,AbstractMarkedContentNode,AbstractMarkedNode,AbstractNode,AbstractTableCellNode,Alignment,Annotation,BlockCard,Blockquote,BodiedExtension,Border,Breakout,BulletList,Caption,Code,CodeBlock,DataConsumer,Date,DecisionItem,DecisionList,Doc,Em,EmbedCard,Emoji,Expand,Extension,Fragment,HardBreak,Heading,Indentation,InlineCard,InlineExtension,LayoutColumn,LayoutSection,Link,ListItem,Media.AbstractMedia,Media.ExternalMedia,Media.FileMedia,Media.FileOrLinkMedia,Media.LinkMedia,MediaGroup,MediaInline,MediaSingle,Mention,NestedExpand,OrderedList,Panel,Paragraph,Placeholder,Rule,Status,Strike,Strong,SubSup,Table,TableCell,TableHeader,TableRow,TaskItem,TaskList,Text,TextColor,Underline,UnsupportedElement,UnsupportedNode,UnsupportedTextMark
public interface ElementAny object within the Atlassian Document Format (ADF) structure.The term "element" is not defined by the JSON schema and is not used by documentation outside of this library, but it has been introduced here to declare features that are common to both
nodes(which represent content) andmarks(which are attached to a node to alter its presentation). For example, both nodes and marks must set atype, so that key and theelementType()method to return its value are both declared here.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceElement.Attrstatic interfaceElement.Key
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Elementcopy()Returns a deep copy of this element, including copies of any nodes or marks that it contains.StringelementType()Thetypevalue that identifies this element, such as"paragraph"or"strong".booleanisSupported()Indicates whether this element is fully supported by this library.static StringnonEmpty(String value, String propertyName)A convenience method used during parsing to throw aMissingPropertyexception for missing required values orEmptyPropertyexception if the value provided is an empty string.static <T> TnonNull(T value, String propertyName)A convenience method used during parsing to throw aMissingPropertyexception for missing required values.static StringnullOrNonEmpty(String value, String propertyName)A convenience method used during parsing to throw anEmptyPropertyexception if the value provided is an empty string, while still permittingnull.Map<String,?>toMap()Transforms this element to a map ofStringvalues to various basic object types suitable for direct rendering as JSON content.voidvalidate()Verifies that the node is well-formed (including the state of any descendents that it has).
-
-
-
Method Detail
-
elementType
String elementType()
Thetypevalue that identifies this element, such as"paragraph"or"strong".
-
toMap
Map<String,?> toMap()
Transforms this element to a map ofStringvalues 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 alistItem) 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, 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.
- Returns:
- a copy of this element, or
thisif the element is immutable anyway - Throws:
AdfException- as fortoMap()
-
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 returnfalsefor this value.- Returns:
truefor fully supported elements;falsefor 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 aMissingPropertyexception for missing required values.- Type Parameters:
T- the inferred type ofvalue- Parameters:
value- the value to checkpropertyName- the name of the property that the value was read from- Returns:
value, which has been verified as non-null- Throws:
AdfException.MissingProperty- ifvalueisnull
-
nullOrNonEmpty
@Nullable static String nullOrNonEmpty(@Nullable String value, String propertyName)
A convenience method used during parsing to throw anEmptyPropertyexception if the value provided is an empty string, while still permittingnull.- Parameters:
value- the value to checkpropertyName- the name of the property that the value was read from- Returns:
value, which may benull, but will not be""- Throws:
AdfException.EmptyProperty- ifvalueis""
-
nonEmpty
static String nonEmpty(String value, String propertyName)
A convenience method used during parsing to throw aMissingPropertyexception for missing required values orEmptyPropertyexception if the value provided is an empty string.- Parameters:
value- the value to checkpropertyName- the name of the property that the value was read from- Returns:
value, which has been verified as non-null- Throws:
AdfException.MissingProperty- ifvalueisnullAdfException.EmptyProperty- ifvalueis""
-
-