Class GadgetState

java.lang.Object
com.atlassian.gadgets.GadgetState
All Implemented Interfaces:
DashboardItemState, Serializable

@Immutable public class GadgetState extends Object implements DashboardItemState, Serializable

An immutable extension of DashboardItemState. GadgetState state extends the DashboardItemState with:

  • a spec URI, indicating where the gadget spec is located
  • a Map of the user preference values

GadgetState objects should be built using the builders. At a minimum, the GadgetId and spec URI are required.

By doing a static import of the gadget(GadgetId) method, you can create a GadgetState object with:

     GadgetState state = gadget(GadgetId.from(1000)).specUri("http://gadget/url").build();
 
Or you can build a new GadgetState object from an existing one with:
     GadgetState state = gadget(originalState).color(color1).build();
 

GadgetState implements the Serializable marker interface. Serialization is only implemented so that GadgetState objects may be distributed among remote systems that might be sharing a cache or need to transfer GadgetStates for other reasons. Serialization is not meant to be used as a means of persisting GadgetState objects between JVM restarts.

See Also:
  • Method Details

    • getId

      public GadgetId getId()
      Returns the unique identifier, represented by a GadgetId, for the gadget's state.
      Specified by:
      getId in interface DashboardItemState
      Returns:
      the unique identifier for this gadget's state.
    • getGadgetSpecUri

      public URI getGadgetSpecUri()
      Returns the URI of the gadget spec, which defines the gadget as described in the gadget spec reference.
      Returns:
      URI of the gadget spec
    • getColor

      public Color getColor()
      Returns the Color scheme that should be used to decorate the chrome surrounding the gadget.
      Specified by:
      getColor in interface DashboardItemState
      Returns:
      the Color scheme that should be used to decorate the chrome surrounding the gadget
    • getUserPrefs

      public Map<String,String> getUserPrefs()
      An immutable Map of the user preference values for the gadget, keyed by the name of the user preference.
      Returns:
      immutable Map of the user preference values for the gadget
    • accept

      public <V> V accept(DashboardItemStateVisitor<V> visitor)
      Specified by:
      accept in interface DashboardItemState
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • gadget

      public static GadgetState.Builder gadget(GadgetState state)
      Factory method which allows you to create a new GadgetState object based on an existing GadgetState.
      Parameters:
      state - the GadgetState to start with when building the new GadgetState
      Returns:
      a Builder which allows you to set the color or change the user preference values
    • gadget

      public static GadgetState.SpecUriBuilder gadget(GadgetId gadgetId)
      Factory method to create a new builder which can be used to create GadgetState objects. It returns a SpecUriBuilder which allows you to set the location of the gadget spec.
      Parameters:
      gadgetId - unique ID for the new GadgetState object
      Returns:
      a SpecUriBuilder which can be used to set the location of the gadget spec