Class BlockCard
- java.lang.Object
-
- com.atlassian.adf.model.node.AbstractNode<BlockCard>
-
- com.atlassian.adf.model.node.BlockCard
-
- All Implemented Interfaces:
Element,Node,DocContent,LayoutColumnContent,NonNestableBlockContent,PanelContent,TableCellContent
@Documentation(state=UNDOCUMENTED, date="2023-07-26") public class BlockCard extends AbstractNode<BlockCard> implements DocContent, LayoutColumnContent, NonNestableBlockContent, PanelContent, TableCellContent
TheblockCardnode is an Atlassian link card with a type icon and content description derived from the link. It provides the same functionality thatinlineCarddoes, but renders its link as a standalone block rather than in combination with the other inline content in aparagraphor similar container.Additionally, block cards have a special "datasource" configuration that provides more dynamic linking capabilities. Use
to build these.blockCard().datasource()Example
Java
doc(p("Hello"),blockCard("https://jira.atlassian.com/browse/JRACLOUD-72220"),p("World") );ADF
{ "type": "doc", "version": 1, "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": "Hello" } ] }, { "type": "blockCard", "attrs": { "url": "https://jira.atlassian.com/browse/JRACLOUD-72220" } }, { "type": "paragraph", "content": [ { "type": "text", "text": "World" } ] } ] }Result
Note: This example output is not using AtlasKit to render the block card, so while it gives a vague impression of what a "block card" is, it does not faithfully reproduce the actual presentation in Atlassian products.
- See Also:
InlineCard
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBlockCard.CardAttributesA sum type providing access to the link data for this card.static classBlockCard.DatasourceAblockCardnode withtype=datasourceis not really a normal block card.static interfaceBlockCard.PartialTypes that represent a partially constructedblockCardorinlineCard.static classBlockCard.View-
Nested classes/interfaces inherited from class com.atlassian.adf.model.node.AbstractNode
AbstractNode.ToStringHelper
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendNodeFields(AbstractNode.ToStringHelper buf)Allows nodes that have their own fields to augment thetoString()implementation with their own field values.static BlockCard.Partial.NeedsCardAttributesblockCard()Creates a partially constructed block card that requires its URI or data to be set before it is valid.static BlockCardblockCard(String url)Creates a block card for the linked content with the given URI.static BlockCardblockCard(URI url)Creates a block card for the linked content with the given URI.static BlockCardblockCard(URL url)Creates a block card for the linked content with the given URI.static BlockCardblockCard(Map<String,?> data)Creates a block card for the linked content with the given JSON-LD description.BlockCard.CardAttributescardAttributes()Returns the card's link data, either as aURIor as aMapcontaining a JSON-LD.BlockCardcopy()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".protected booleannodeEquals(BlockCard 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.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).-
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
isSupported
-
Methods inherited from interface com.atlassian.adf.model.node.Node
appendPlainText, toPlainText
-
-
-
-
Method Detail
-
blockCard
@CheckReturnValue public static BlockCard.Partial.NeedsCardAttributes blockCard()
Creates a partially constructed block card that requires its URI or data to be set before it is valid.- Returns:
- a partially constructed block card
-
blockCard
public static BlockCard blockCard(String url)
Creates a block card for the linked content with the given URI.- Parameters:
url- the target URI for the block card- Returns:
- a new block card for the given URI
- Throws:
IllegalArgumentException- if the URI cannot be parsed
-
blockCard
public static BlockCard blockCard(URL url)
Creates a block card for the linked content with the given URI.- Parameters:
url- the target URI for the block card- Returns:
- a new block card for the given URI
-
blockCard
public static BlockCard blockCard(URI url)
Creates a block card for the linked content with the given URI.- Parameters:
url- the target URI for the block card- Returns:
- a new block card for the given URI
-
blockCard
public static BlockCard blockCard(Map<String,?> data)
Creates a block card for the linked content with the given JSON-LD description.- Parameters:
data- the link description data in JSON-LD format- Returns:
- a new block card for the given JSON-LD
-
copy
public BlockCard 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.
-
validate
public void validate()
Description copied from interface:ElementVerifies that the node is well-formed (including the state of any descendents that it has).
-
elementType
public String elementType()
Description copied from interface:ElementThetypevalue that identifies this element, such as"paragraph"or"strong".- Specified by:
elementTypein interfaceElement
-
nodeEquals
protected final boolean nodeEquals(BlockCard 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<BlockCard>- 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)
-
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<BlockCard>- 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)
-
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<BlockCard>- Parameters:
buf- where the field values should be written- See Also:
AbstractNode.nodeHashCode(),AbstractNode.nodeEquals(AbstractNode)
-
toMap
public final Map<String,?> toMap()
Description copied from interface:ElementTransforms this element to a map ofStringvalues to various basic object types suitable for direct rendering as JSON content.
-
cardAttributes
public BlockCard.CardAttributes cardAttributes()
Returns the card's link data, either as aURIor as aMapcontaining a JSON-LD.- Returns:
- the card's link data, either as a
URIor as aMapcontaining a JSON-LD.
-
-