com.atlassian.gadgets
Class GadgetState

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

@Immutable
public final class GadgetState
extends Object
implements Serializable

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

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

Nested Class Summary
static class GadgetState.Builder
          A builder that allows you to set the Color and the user preferences of the GadgetState under construction.
static class GadgetState.SpecUriBuilder
          A builder that allows you to set the spec URI of the gadget state under construction
 
Method Summary
 boolean equals(Object o)
           
static GadgetState.SpecUriBuilder gadget(GadgetId gadgetId)
          Factory method to create a new builder which can be used to create GadgetState objects.
static GadgetState.Builder gadget(GadgetState state)
          Factory method which allows you to create a new GadgetState object based on an existing GadgetState.
 Color getColor()
          Returns the Color scheme that should be used to decorate the chrome surrounding the gadget.
 URI getGadgetSpecUri()
          Returns the URI of the gadget spec, which defines the gadget as described in the gadget spec reference.
 GadgetId getId()
          Returns the unique identifier, represented by a GadgetId, for the gadget's state.
 Map<String,String> getUserPrefs()
          An immutable Map of the user preference values for the gadget, keyed by the name of the user preference.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getId

public GadgetId getId()
Returns the unique identifier, represented by a GadgetId, for the gadget's state.

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.

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

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


Copyright © 2010 Atlassian. All Rights Reserved.