com.ashridgetech.jamda.uml
Class PropertyBuilder

java.lang.Object
  |
  +--com.ashridgetech.jamda.uml.PropertyBuilder

public class PropertyBuilder
extends java.lang.Object

A builder object for creating Property objects, either based on an existing Property, or completely new. The client creates an instance of PropertyBuilder, sets the base property if required, then calls the various setXXX methods to set the characteristics of the new Property, then finally calls getProperty() to create the new Property. The builder may be reused if required by calling start(com.ashridgetech.jamda.uml.Property) again. Note: this class is not thread-safe. It will detect attempts to call start(com.ashridgetech.jamda.uml.Property) again before getProperty() has been called.

Version:
1.0
Author:
paulb

Nested Class Summary
protected static class PropertyBuilder.PropertyImpl
          Implementation of the Property interface returned by getProperty().
 
Constructor Summary
PropertyBuilder()
          Construct a PropertyBuilder which is not connected to a base property.
PropertyBuilder(Property baseProperty)
          Construct a PropertyBuilder which is connected to a base property.
PropertyBuilder(java.lang.String name, Type type)
          Construct a PropertyBuilder which is not connected to a base property, but has the name and type set.
 
Method Summary
 Property getBaseProperty()
          Get the Property whose characteristics are the starting point for the new Property
 Property getProperty()
          Get the new Property whose characteristics have been set.
 boolean isBuilding()
          Show whether this instance is in the 'building' state.
static Property makeProperty(java.lang.String name, Type type)
          Construct a Property object with just a name and type.
 void setAggregation(StructuredType.Aggregation aggregation)
          Set the aggregation level of this property.
 void setComment(java.lang.String comment)
          Set the Type of this Property
 void setMultiple(boolean multiple)
          Set whether this Property can have multiple values.
 void setName(java.lang.String name)
          Set the name of the new Property.
 void setOid(boolean oid)
          Set whether this property is an object identifier (OID)
 void setReadable(boolean readable)
          Set whether this Property is readable.
 void setReaders(java.util.Set readers)
          Set the Actors who can read this Property
 void setType(Type type)
          Set the Type of the new Property.
 void setUnderlying(Association.End associationEnd)
          Set the underlying element of the new property to be an Association.End.
 void setUnderlying(Attribute attribute)
          Set the underlying element of the new property to be an Attribute.
 void setUnderlying(Operation getter, Operation setter, Attribute attribute)
          Set the underlying element of the new property to be some combination of getter, setter and attribute.
 void setUnderlying(Parameter parameter)
          Set the underlying element of the new property to be an Parameter.
 void setWritable(boolean writable)
          Set whether this Property is writable.
 void setWriters(java.util.Set writers)
          Set the Actors who can write this Property
 void start(Property baseProperty)
          Start a new Property and set the Property whose characteristics are the starting point for the new Property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyBuilder

public PropertyBuilder()
Construct a PropertyBuilder which is not connected to a base property. Does NOT put this instance into the building state. The start(com.ashridgetech.jamda.uml.Property) method must be called before any setXXX methods can be called.

See Also:
start(com.ashridgetech.jamda.uml.Property)

PropertyBuilder

public PropertyBuilder(java.lang.String name,
                       Type type)
Construct a PropertyBuilder which is not connected to a base property, but has the name and type set. Puts this instance into the building state.

Parameters:
name - the name of the new Property.
type - the type of the new Property.

PropertyBuilder

public PropertyBuilder(Property baseProperty)
Construct a PropertyBuilder which is connected to a base property. Puts this instance into the building state.

Parameters:
baseProperty - the Property whose characteristics are the starting point for the new Property
See Also:
start(com.ashridgetech.jamda.uml.Property)
Method Detail

makeProperty

public static Property makeProperty(java.lang.String name,
                                    Type type)
Construct a Property object with just a name and type.

Parameters:
name - the name of the new Property.
type - the type of the new Property.
Returns:
the new Property

getBaseProperty

public Property getBaseProperty()
Get the Property whose characteristics are the starting point for the new Property

Returns:
the base Property - may be null

start

public void start(Property baseProperty)
Start a new Property and set the Property whose characteristics are the starting point for the new Property. Puts this instance into the building state. Cannot be called again until after getProperty() has been called.

Parameters:
baseProperty - the base property to set. May be null to start a new Property with no base property
Throws:
java.lang.IllegalStateException - if this instance is already in the building state

isBuilding

public boolean isBuilding()
Show whether this instance is in the 'building' state. This means that it is ready to accept zero or more calls to methods which set the characteristics, followed by a call to getProperty().

Returns:
true if this instance is 'building'
See Also:
start(com.ashridgetech.jamda.uml.Property), getProperty()

getProperty

public Property getProperty()
Get the new Property whose characteristics have been set. This instance must be in the building state. Resets this instance so that it is no longer in the building state.

Returns:
the new Property
Throws:
java.lang.IllegalStateException - if this instance is not in the building state

setName

public void setName(java.lang.String name)
Set the name of the new Property.

Parameters:
name - the new name

setType

public void setType(Type type)
Set the Type of the new Property.

Parameters:
type - the new Type

setComment

public void setComment(java.lang.String comment)
Set the Type of this Property


setMultiple

public void setMultiple(boolean multiple)
Set whether this Property can have multiple values.

Parameters:
multiple - true if the Property has multiple values

setReadable

public void setReadable(boolean readable)
Set whether this Property is readable.

Parameters:
readable - true if the Property is readable

setReaders

public void setReaders(java.util.Set readers)
Set the Actors who can read this Property

Parameters:
readers - the set of Actors. See Property.getReaders() for the values allowed.

setWritable

public void setWritable(boolean writable)
Set whether this Property is writable.

Parameters:
writable - true if the Property is writable

setWriters

public void setWriters(java.util.Set writers)
Set the Actors who can write this Property

Parameters:
writers - the set of Actors. See Property.getWriters() for the values allowed.

setAggregation

public void setAggregation(StructuredType.Aggregation aggregation)
Set the aggregation level of this property.

Parameters:
aggregation - the new Aggregation instance

setOid

public void setOid(boolean oid)
Set whether this property is an object identifier (OID)

Parameters:
oid - true if this Property is an oid

setUnderlying

public void setUnderlying(Attribute attribute)
Set the underlying element of the new property to be an Attribute. The getter, setter and association end are all set to null.

Parameters:
attribute - the new underlying element - may not be null

setUnderlying

public void setUnderlying(Association.End associationEnd)
Set the underlying element of the new property to be an Association.End. The getter, setter and attribute are all set to null.

Parameters:
associationEnd - the new underlying element - may not be null

setUnderlying

public void setUnderlying(Operation getter,
                          Operation setter,
                          Attribute attribute)
Set the underlying element of the new property to be some combination of getter, setter and attribute. The association end is set to null.

Parameters:
getter - the getter Operation associated with this Property - may be null if setter is not null
setter - the setter Operation associated with this Property - may be null if getter is not null

setUnderlying

public void setUnderlying(Parameter parameter)
Set the underlying element of the new property to be an Parameter. The getter, setter, attribute and association end are all set to null.

Parameters:
parameter - the new underlying element - may not be null


Copyright © 2003 Ashridge Technologies Ltd. All Rights Reserved.