Class DashboardState

java.lang.Object
com.atlassian.gadgets.dashboard.DashboardState
All Implemented Interfaces:
Serializable

@Immutable public class DashboardState extends Object implements Serializable

An immutable representation of a dashboard. A dashboard's state consists of

  • a DashboardId, used to uniquely identify the dashboard within the system
  • a title, the text that is displayed to the user
  • a Layout that describes how many columns appear on the dashboard and how large they should be with respect to one another
  • GadgetStates that represent the gadgets in the dashboard represented by this DashboardState are found in columns

DashboardState objects should be built using the builders. At a minimum, the DashboardId and the title are required.

By doing a static import of the dashboard(DashboardId) method, you can create a DashboardState object with:

     DashboardState state = dashboard(DashboardId.from(1000)).title("Menagerie").build();
 

Or you can create a new DashboardState object from an existing one:

     DashboardState state = dashboard(originalState).layout(Layout.AAA).build();
 

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

See Also:
  • Method Details

    • getId

      public DashboardId getId()
      Returns the unique identifier, represented by a DashboardId, for the dashboard's state.
      Returns:
      the unique identifier for this dashboard's state.
    • getTitle

      public String getTitle()
      Returns the title of the dashboard.
      Returns:
      the title of the dashboard
    • getLayout

      public Layout getLayout()
      Returns the Layout of the dashboard.
      Returns:
      the Layout of the dashboard
    • getGadgetsInColumn

      @Deprecated public Iterable<GadgetState> getGadgetsInColumn(DashboardState.ColumnIndex column)
      Deprecated.
      Returns an immutable Iterable of the GadgetStates in the given column. They are returned in the order that they appear on the dashboard from top to bottom.
      Parameters:
      column - the index of the column to retrieve the GadgetStates for
      Returns:
      an immutable Iterable of the GadgetState in the column deprecated Use getDashboardColumns() instead. Since v3.11.
    • getColumns

      @Deprecated public Iterable<? extends Iterable<GadgetState>> getColumns()
      Deprecated.
      Returns an immutable Iterable of the columns in this DashboardState (which contain the GadgetStates).
    • getDashboardColumns

      public DashboardColumns getDashboardColumns()
    • getVersion

      public long getVersion()
      Returns this state's version so that it can be used by implementations when storing DashboardStates, to make sure the same object is stored and retrieved
      Returns:
      the version
    • prependGadgetToColumn

      @Deprecated public DashboardState prependGadgetToColumn(GadgetState dashboardItemState, DashboardState.ColumnIndex index)
      Returns a new DashboardState built with the same data as this, except that the column with index index has had a new gadget added to its top
      Parameters:
      dashboardItemState - the new gadget to add
      index - the index of the column to add the new state to
      Returns:
      the new DashboardState
    • appendGadgetToColumn

      @Deprecated public DashboardState appendGadgetToColumn(GadgetState gadgetState, DashboardState.ColumnIndex index)
      Deprecated.
      Returns a new DashboardState built with the same data as this, except that the column with index index has had a new gadget added to its bottom
      Parameters:
      gadgetState - the new gadget to add
      index - the index of the column to add the new state to
      Returns:
      the new DashboardState deprecated Use prependItemToColumn(com.atlassian.gadgets.DashboardItemState, com.atlassian.gadgets.dashboard.DashboardState.ColumnIndex) instead. Since v3.11.
    • prependItemToColumn

      public DashboardState prependItemToColumn(DashboardItemState itemState, DashboardState.ColumnIndex index)
      Returns a new DashboardState built with the same data as this, except that the column with index index has had a new gadget added to its top
      Parameters:
      itemState - the new dashboard item to add
      index - the index of the column to add the new state to
      Returns:
      the new DashboardState
    • appendItemToColumn

      public DashboardState appendItemToColumn(DashboardItemState itemState, DashboardState.ColumnIndex index)
      Returns a new DashboardState built with the same data as this, except that the column with index index has had a new gadget added to its bottom
      Parameters:
      itemState - the new dashboard item to add
      index - the index of the column to add the new state to
      Returns:
      the new DashboardState
    • 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
    • dashboard

      public static DashboardState.Builder dashboard(DashboardState state)
      Factory method which allows you to create a new DashboardState object based on an existing DashboardState.
      Parameters:
      state - the DashboardState to start with when building the new DashboardState
      Returns:
      a GadgetState.Builder which allows you to set the layout or change the columns
    • dashboard

      public static DashboardState.TitleBuilder dashboard(DashboardId id)
      Factory method to create a new builder which can be used to create DashboardState objects. It returns a TitleBuilder which only allows you to set the title. After setting the title, a Builder will be returned allowing other properties to be set.
      Parameters:
      id - unique identifier for the new DashboardState object
      Returns:
      a TitleBuilder which can be used to set the title of the dashboard