org.kuali.rice.krms.api.repository.context
Class ContextDefinition.Builder

java.lang.Object
  extended by org.kuali.rice.krms.api.repository.context.ContextDefinition.Builder
All Implemented Interfaces:
Serializable, Inactivatable, Identifiable, Versioned, ModelBuilder, ContextDefinitionContract
Enclosing class:
ContextDefinition

public static final class ContextDefinition.Builder
extends Object
implements ContextDefinitionContract, ModelBuilder, Serializable

A builder which can be used to construct ContextDefinition instances. Enforces the constraints of the ContextDefinitionContract. This class is the only means by which a ContextDefinition object can be constructed.

Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
Serialized Form

Method Summary
 ContextDefinition build()
          Returns an instance of the object being built by this builder based on the current state of the builder.
static ContextDefinition.Builder create(ContextDefinitionContract contract)
          Creates a populates a builder with the data on the given ContextDefinitionContract.
static ContextDefinition.Builder create(String namespace, String name)
          Creates a context definition builder with the given required values
 List<AgendaDefinition.Builder> getAgendas()
          Returns the list of agendas AgendaDefinitionContract contained in the context definition.
 Map<String,String> getAttributes()
          Returns a map of name/value pairs representing the attributes associated with this context.
 String getDescription()
          Returns the description of the context definition.
 String getId()
          The unique identifier for an object.
 String getName()
          Returns the name of the context definition.
 String getNamespace()
          Returns the namespace of the context definition.
 String getTypeId()
          Returns the type id for the context definition.
 Long getVersionNumber()
          Returns the version number for this object.
 boolean isActive()
          The active indicator for an object.
 void setActive(boolean active)
          Sets the active flag for the context that will be returned by this builder.
 void setAgendas(List<? extends AgendaDefinitionContract> agendaContracts)
          Sets the agendas property of this context definition.
 void setAttributes(Map<String,String> attributes)
          Sets the Map of attributes as name / value pairs.
 void setDescription(String description)
          Sets the description for the context definition that will be created by this builder.
 void setId(String id)
          Sets the id for the context definition that will be created by this builder.
 void setName(String name)
          Sets the name for the context definition that will be created by this builder.
 void setNamespace(String namespace)
          Sets the namespace code for the context definition that will be created by this builder.
 void setTypeId(String typeId)
          Sets the typeId for the context definition that will be created by this builder.
 void setVersionNumber(Long versionNumber)
          Sets the version number for the style that will be returned by this builder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static ContextDefinition.Builder create(String namespace,
                                               String name)
Creates a context definition builder with the given required values

Parameters:
namespace - the namespace code of the context definition to create, must not be null or blank
name - the name of the context definition to create, must not be null or blank
Returns:
a builder with the required values already initialized
Throws:
IllegalArgumentException - if the given namespace is null or blank
IllegalArgumentException - if the given name is null or blank

create

public static ContextDefinition.Builder create(ContextDefinitionContract contract)
Creates a populates a builder with the data on the given ContextDefinitionContract. This is similar in nature to a "copy constructor" for Style.

Parameters:
contract - an object implementing the ContextDefinitionContract from which to copy property values
Returns:
a builder with the values from the contract already initialized
Throws:
IllegalArgumentException - if the given contract is null

build

public ContextDefinition build()
Description copied from interface: ModelBuilder
Returns an instance of the object being built by this builder based on the current state of the builder. It should be possible to invoke this method more than once on the same builder. It should never return null;

Specified by:
build in interface ModelBuilder
Returns:
an instance of the object being built by this builder, should never return null

getVersionNumber

public Long getVersionNumber()
Description copied from interface: Versioned
Returns the version number for this object. In general, this value should only be null if the object has not yet been stored to a persistent data store. This version number is generally used for the purposes of optimistic locking.

Specified by:
getVersionNumber in interface Versioned
Returns:
the version number, or null if one has not been assigned yet

getId

public String getId()
Description copied from interface: Identifiable
The unique identifier for an object. This can be null.

Specified by:
getId in interface Identifiable
Returns:
the id

getNamespace

public String getNamespace()
Description copied from interface: ContextDefinitionContract
Returns the namespace of the context definition. The combination of namespace and name represent a unique business key for the context definition. The namespace should never be null or blank.

Specified by:
getNamespace in interface ContextDefinitionContract
Returns:
the namespace of the context definition, should never be null or blank

getName

public String getName()
Description copied from interface: ContextDefinitionContract
Returns the name of the context definition. The combination of name and namespaceCode represent a unique business key for the context definition. The name should never be null or blank.

Specified by:
getName in interface ContextDefinitionContract
Returns:
the name of the context definition, should never be null or blank

getTypeId

public String getTypeId()
Description copied from interface: ContextDefinitionContract
Returns the type id for the context definition. If the type id is null, that means this context definition is of the default type.

Specified by:
getTypeId in interface ContextDefinitionContract
Returns:
the type id for the context definition, or null if this context definition is of the default type

getDescription

public String getDescription()
Description copied from interface: ContextDefinitionContract
Returns the description of the context definition.

Specified by:
getDescription in interface ContextDefinitionContract
Returns:
the description of the context definition. May be null.

isActive

public boolean isActive()
Description copied from interface: Inactivatable
The active indicator for an object.

Specified by:
isActive in interface Inactivatable
Returns:
true if active false if not.

getAgendas

public List<AgendaDefinition.Builder> getAgendas()
Description copied from interface: ContextDefinitionContract
Returns the list of agendas AgendaDefinitionContract contained in the context definition. This method should never return null. An empty list is returned if no agendas are associated with this context.

Specified by:
getAgendas in interface ContextDefinitionContract
Returns:
the list of agendas contained in this context definition

getAttributes

public Map<String,String> getAttributes()
Description copied from interface: ContextDefinitionContract
Returns a map of name/value pairs representing the attributes associated with this context.

This method should never return null. An empty map is returned if no attributes are associated with the context.

Specified by:
getAttributes in interface ContextDefinitionContract
Returns:
a list of Map of name/value String pairs.

setId

public void setId(String id)
Sets the id for the context definition that will be created by this builder.

Parameters:
id - the id to set

setNamespace

public void setNamespace(String namespace)
Sets the namespace code for the context definition that will be created by this builder. The namespace code must not be blank or null.

Parameters:
namespace - the namespace to set on this builder, must not be null or blank
Throws:
IllegalArgumentException - if the given namespace code is null or blank

setName

public void setName(String name)
Sets the name for the context definition that will be created by this builder. The name must not be blank or null.

Parameters:
name - the name to set on this builder, must not be null or blank
Throws:
IllegalArgumentException - if the given name is null or blank

setTypeId

public void setTypeId(String typeId)
Sets the typeId for the context definition that will be created by this builder.

Parameters:
typeId - the typeId to set

setDescription

public void setDescription(String description)
Sets the description for the context definition that will be created by this builder.

Parameters:
description - the descripition to set

setActive

public void setActive(boolean active)
Sets the active flag for the context that will be returned by this builder.

Parameters:
active - the active flag to set

setAgendas

public void setAgendas(List<? extends AgendaDefinitionContract> agendaContracts)
Sets the agendas property of this context definition.

For each of the AgendaDefinitionContract provided in the parameter list, construct an AgendaDefinition from the builder of the provided contract, and save the agenda definitions in a List of AgendaDefinition

Parameters:
agendaContracts - a list of agenda definition contracts

setAttributes

public void setAttributes(Map<String,String> attributes)
Sets the Map of attributes as name / value pairs.

Parameters:
attributes - a Map of name value String pairs respresenting the attributes associated with this context

setVersionNumber

public void setVersionNumber(Long versionNumber)
Sets the version number for the style that will be returned by this builder.

In general, this value should not be manually set on the builder, but rather copied from an existing ContextDefinitionContract when invoking create(ContextDefinitionContract).

Parameters:
versionNumber - the version number to set


Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.