com.atlassian.gadgets.dashboard
Class DashboardState

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

@Immutable
public final class DashboardState
extends Object
implements Serializable

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

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:
Serialized Form

Nested Class Summary
static class DashboardState.Builder
          A builder that allows the Layout or the columns of the DashboardState under construction to be set.
static class DashboardState.ColumnIndex
          There are a predetermined number of columns that a dashboard can contain, and ColumnIndex is the enumeration of those columns.
static class DashboardState.TitleBuilder
          A builder that allows you to set the title of the DashboardState object under construction.
 
Method Summary
 DashboardState appendGadgetToColumn(GadgetState gadgetState, 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
static DashboardState.TitleBuilder dashboard(DashboardId id)
          Factory method to create a new builder which can be used to create DashboardState objects.
static DashboardState.Builder dashboard(DashboardState state)
          Factory method which allows you to create a new DashboardState object based on an existing DashboardState.
 boolean equals(Object o)
           
 Iterable<? extends Iterable<GadgetState>> getColumns()
          Returns an immutable Iterable of the columns in this DashboardState (which contain the GadgetStates).
 Iterable<GadgetState> getGadgetsInColumn(DashboardState.ColumnIndex column)
          Returns an immutable Iterable of the GadgetStates in the given column.
 DashboardId getId()
          Returns the unique identifier, represented by a DashboardId, for the dashboard's state.
 Layout getLayout()
          Returns the Layout of the dashboard.
 String getTitle()
          Returns the title of the dashboard.
 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
 int hashCode()
           
 DashboardState prependGadgetToColumn(GadgetState gadgetState, 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
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

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

public Iterable<GadgetState> getGadgetsInColumn(DashboardState.ColumnIndex column)
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

getColumns

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


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

public DashboardState prependGadgetToColumn(GadgetState gadgetState,
                                            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:
gadgetState - the new gadget to add
index - the index of the column to add the new state to
Returns:
the new DashboardState

appendGadgetToColumn

public DashboardState appendGadgetToColumn(GadgetState gadgetState,
                                           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:
gadgetState - the new gadget 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


Copyright © 2011 Atlassian. All Rights Reserved.