Class MacroDefinition
- java.lang.Object
-
- com.atlassian.confluence.xhtml.api.MacroDefinition
-
public class MacroDefinition extends Object
An object that encapsulates the state for a macro.
-
-
Field Summary
Fields Modifier and Type Field Description static int
INITIAL_SCHEMA_VERSION
static String
STORAGE_VERSION_1
static String
STORAGE_VERSION_2
-
Constructor Summary
Constructors Constructor Description MacroDefinition(MacroDefinition macroDefinition)
Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static MacroDefinitionBuilder
builder()
The correct way to construct a new MacroDefinition.static MacroDefinitionBuilder
builder(String macroName)
The correct way to construct a new MacroDefinition.boolean
equals(Object o)
MacroBody
getBody()
Streamable
getBodyStream()
String
getBodyText()
Macro.BodyType
getBodyType()
String
getDefaultParameterValue()
Equivalent togetParameter(java.lang.String)
orgetTypedParameter(java.lang.String, java.lang.Class<T>)
with ""com.atlassian.fugue.Option<MacroId>
getMacroId()
Deprecated.since 7.0.1.Optional<MacroId>
getMacroIdentifier()
Each macro definition is assigned a macroId when the page is stored, this can be used to identify macros within a page.String
getName()
String
getParameter(String name)
Map<String,String>
getParameters()
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.Streamable
getStorageBodyStream()
String
getStorageBodyText()
String
getStorageVersion()
Streamable
getTransformedBodyStream()
<T> T
getTypedParameter(String name, Class<T> type)
Map<String,Object>
getTypedParameters()
boolean
hasBody()
int
hashCode()
boolean
isValid()
String
macroHash()
The macroHash is used to identify a macro if there is no macroId stored.void
setBody(MacroBody body)
void
setDefaultParameterValue(String defaultParameterValue)
void
setMacroId(com.atlassian.fugue.Option<MacroId> macroId)
Deprecated.since 7.0.1.void
setMacroIdentifier(@Nullable MacroId macroId)
void
setName(String name)
void
setParameter(String name, String value)
void
setParameters(Map<String,String> parameters)
void
setSchemaVersion(int schemaVersion)
void
setStorageVersion(String storageVersion)
void
setTypedParameter(String name, Object value)
void
setTypedParameters(Map<String,Object> typedParameters)
String
toString()
-
-
-
Field Detail
-
STORAGE_VERSION_1
public static final String STORAGE_VERSION_1
- See Also:
- Constant Field Values
-
STORAGE_VERSION_2
public static final String STORAGE_VERSION_2
- See Also:
- Constant Field Values
-
INITIAL_SCHEMA_VERSION
public static final int INITIAL_SCHEMA_VERSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MacroDefinition
public MacroDefinition(MacroDefinition macroDefinition)
Copy constructor.- Parameters:
macroDefinition
- copy the state of this macro definition into this new instance
-
-
Method Detail
-
builder
public static MacroDefinitionBuilder builder()
The correct way to construct a new MacroDefinition. Get a builder, load it, and build it.
-
builder
public static MacroDefinitionBuilder builder(String macroName)
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
public String getName()
-
getDefaultParameterValue
public String 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
public String getBodyText()
- Returns:
- the body as a string. Can be empty. May be transformed, if that is the required format.
- See Also:
getStorageBodyStream()
,getTransformedBodyStream()
,RequiresFormat
-
getBodyStream
public Streamable getBodyStream()
- Returns:
- the body as a stream. Can be empty. May be transformed, if that is the required format.
- See Also:
getStorageBodyStream()
,getTransformedBodyStream()
,RequiresFormat
-
getStorageBodyText
public String getStorageBodyText()
- Returns:
- the storage body as a string. Can be empty.
- See Also:
getStorageBodyStream()
-
getStorageBodyStream
public Streamable getStorageBodyStream()
-
getTransformedBodyStream
public Streamable getTransformedBodyStream()
-
getBody
public MacroBody getBody()
-
getBodyType
public Macro.BodyType getBodyType()
- Returns:
- the body type that is returned from #getBody
- Since:
- 5.9.8
-
hasBody
public boolean hasBody()
-
setName
public void setName(String name)
-
setDefaultParameterValue
public void setDefaultParameterValue(String defaultParameterValue)
-
setBody
public void setBody(MacroBody body)
-
getStorageVersion
public String getStorageVersion()
-
setStorageVersion
public void setStorageVersion(String storageVersion)
-
getMacroId
@Deprecated public com.atlassian.fugue.Option<MacroId> 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
public Optional<MacroId> 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 public void setMacroId(com.atlassian.fugue.Option<MacroId> macroId)
Deprecated.since 7.0.1. UsesetMacroIdentifier(MacroId)
-
setMacroIdentifier
public void setMacroIdentifier(@Nullable MacroId macroId)
- 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.
-
macroHash
public String 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
-
-