Class MacroDefinition
java.lang.Object
com.atlassian.confluence.xhtml.api.MacroDefinition
An object that encapsulates the state for a macro.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MacroDefinitionBuilderbuilder()The correct way to construct a new MacroDefinition.static MacroDefinitionBuilderThe correct way to construct a new MacroDefinition.booleangetBody()Equivalent togetParameter(java.lang.String)orgetTypedParameter(java.lang.String, java.lang.Class<T>)with ""com.atlassian.fugue.Option<MacroId>Deprecated.since 7.0.1.Each macro definition is assigned a macroId when the page is stored, this can be used to identify macros within a page.getName()getParameter(String name) intThe macro schema is the definition of the parameters and the macro body, an incompatible change of schema will require an increase in the schema version and a corresponding macro-schema-migration module to migrate from the old schema to the new schema.<T> TgetTypedParameter(String name, Class<T> type) booleanhasBody()inthashCode()booleanisValid()The macroHash is used to identify a macro if there is no macroId stored.voidvoidsetDefaultParameterValue(String defaultParameterValue) voidsetMacroId(com.atlassian.fugue.Option<MacroId> macroId) Deprecated.since 7.0.1.voidsetMacroIdentifier(@Nullable MacroId macroId) voidvoidsetParameter(String name, String value) voidsetParameters(Map<String, String> parameters) voidsetSchemaVersion(int schemaVersion) voidsetStorageVersion(String storageVersion) voidsetTypedParameter(String name, Object value) voidsetTypedParameters(Map<String, Object> typedParameters) toString()
-
Field Details
-
STORAGE_VERSION_1
- See Also:
-
STORAGE_VERSION_2
- See Also:
-
INITIAL_SCHEMA_VERSION
public static final int INITIAL_SCHEMA_VERSION- See Also:
-
-
Constructor Details
-
MacroDefinition
Copy constructor.- Parameters:
macroDefinition- copy the state of this macro definition into this new instance
-
-
Method Details
-
builder
The correct way to construct a new MacroDefinition. Get a builder, load it, and build it. -
builder
The correct way to construct a new MacroDefinition. Get a builder, load it, and build it. Macro names are required at the time of building the definitions, so provide a shortcut here to supply one when creating the builder. -
getName
-
getDefaultParameterValue
Equivalent togetParameter(java.lang.String)orgetTypedParameter(java.lang.String, java.lang.Class<T>)with ""- Returns:
- the value of the default parameter, or null if there isn't one.
-
getBodyText
- Returns:
- the body as a string. Can be empty. May be transformed, if that is the required format.
- See Also:
-
getBodyStream
- Returns:
- the body as a stream. Can be empty. May be transformed, if that is the required format.
- See Also:
-
getStorageBodyText
- Returns:
- the storage body as a string. Can be empty.
- See Also:
-
getStorageBodyStream
-
getTransformedBodyStream
-
getBody
-
getBodyType
- Returns:
- the body type that is returned from #getBody
- Since:
- 5.9.8
-
hasBody
public boolean hasBody() -
getParameters
-
getTypedParameters
-
getParameter
-
getTypedParameter
-
setName
-
setDefaultParameterValue
-
setBody
-
setParameters
-
setTypedParameters
-
setParameter
-
setTypedParameter
-
getStorageVersion
-
setStorageVersion
-
getMacroId
Deprecated.since 7.0.1. UsegetMacroIdentifier()Each macro definition is assigned a macroId when the page is stored, this can be used to identify macros within a page.If there is no macroId specified for this macro, it means the page containing this macro has not yet been saved after the macro id changes were committed to Confluence.
- Returns:
- the id of this macro definition, for use when rendering macros for remote add-ons, or when looking up macros through the ContentMacroService, if one is available.
- Since:
- 5.8
-
getMacroIdentifier
Each macro definition is assigned a macroId when the page is stored, this can be used to identify macros within a page.If there is no macroId specified for this macro, it means the page containing this macro has not yet been saved after the macro id changes were committed to Confluence.
- Returns:
- the id of this macro definition, for use when rendering macros for remote add-ons, or when looking up macros through the ContentMacroService, if one is available.
- Since:
- 7.0.1
-
setMacroId
Deprecated.since 7.0.1. UsesetMacroIdentifier(MacroId) -
setMacroIdentifier
- Since:
- 7.0.1
-
getSchemaVersion
public int getSchemaVersion()The macro schema is the definition of the parameters and the macro body, an incompatible change of schema will require an increase in the schema version and a corresponding macro-schema-migration module to migrate from the old schema to the new schema.- Returns:
- the schema version for this macro definition
-
setSchemaVersion
public void setSchemaVersion(int schemaVersion) -
isValid
public boolean isValid()- Returns:
- true if there is at least a name on this MacroDefinition.
-
toString
-
equals
-
hashCode
public int hashCode() -
macroHash
The macroHash is used to identify a macro if there is no macroId stored. The concept of macro hash's are now only used as backup in favor of macroId's which should be used instead.- Returns:
- the hash of this macro definition, for use when rendering macros for remote add-ons, or when looking up macros through the ContentMacroService when no MacroId is available
- Since:
- 5.6
-