Class MacroDefinition


  • public class MacroDefinition
    extends Object
    An object that encapsulates the state for a macro.
    • 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()
      • 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()
      • getBodyType

        public Macro.BodyType getBodyType()
        Returns:
        the body type that is returned from #getBody
        Since:
        5.9.8
      • hasBody

        public boolean hasBody()
      • getParameter

        public String getParameter​(String name)
      • getTypedParameter

        public <T> T getTypedParameter​(String name,
                                       Class<T> type)
      • setName

        public void setName​(String name)
      • setDefaultParameterValue

        public void setDefaultParameterValue​(String defaultParameterValue)
      • setBody

        public void setBody​(MacroBody body)
      • setParameters

        public void setParameters​(Map<String,​String> parameters)
      • setTypedParameters

        public void setTypedParameters​(Map<String,​Object> typedParameters)
      • setParameter

        public void setParameter​(String name,
                                 String value)
      • setTypedParameter

        public void setTypedParameter​(String name,
                                      Object value)
      • getStorageVersion

        public String getStorageVersion()
      • setStorageVersion

        public void setStorageVersion​(String storageVersion)
      • getMacroId

        @Deprecated
        public com.atlassian.fugue.Option<MacroId> getMacroId()
        Deprecated.
        since 7.0.1. Use 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:
        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
      • 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • 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