org.nakedobjects.metamodel.consent
Class ConsentAbstract

java.lang.Object
  extended by org.nakedobjects.metamodel.consent.ConsentAbstract
All Implemented Interfaces:
java.io.Serializable, Consent
Direct Known Subclasses:
Allow, Veto

public abstract class ConsentAbstract
extends java.lang.Object
implements java.io.Serializable, Consent

See Also:
Serialized Form

Constructor Summary
protected ConsentAbstract(InteractionResult interactionResult)
           
protected ConsentAbstract(java.lang.String description, java.lang.String reason)
          Enable legacy Consents (not created using an InteractionResult) to create an Consent, specifying a description of the event and the reason (if any) that the consent is vetoed.
 
Method Summary
static Consent allowIf(boolean allowed)
          Factory method.
 java.lang.String getDescription()
          Description of the action allowed by this event.
 InteractionResult getInteractionResult()
          Underlying InteractionResult that created this Consent (may be null).
 java.lang.String getReason()
          The reason why this has been vetoed.
 boolean isAllowed()
          Returns true if this object is giving permission (if the reason is null or empty.
 boolean isVetoed()
          Returns true if this object is NOT giving permission.
 Consent setDescription(java.lang.String description)
          Allows the description of the interaction to which this consent relates to be specified or refined.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConsentAbstract

protected ConsentAbstract(InteractionResult interactionResult)
Parameters:
interactionResult - - if null then defaults to an allowing Consent.

ConsentAbstract

protected ConsentAbstract(java.lang.String description,
                          java.lang.String reason)
Enable legacy Consents (not created using an InteractionResult) to create an Consent, specifying a description of the event and the reason (if any) that the consent is vetoed.

Parameters:
description - - a description of the event to which this consent relates
reason - - if not null and not empty, is the reason this consent is vetoed.
Method Detail

allowIf

public static Consent allowIf(boolean allowed)
Factory method.

Used extensively by the DnD viewer.


getReason

public java.lang.String getReason()
The reason why this has been vetoed.

Specified by:
getReason in interface Consent

setDescription

public Consent setDescription(java.lang.String description)
Description copied from interface: Consent
Allows the description of the interaction to which this consent relates to be specified or refined.

Specified by:
setDescription in interface Consent
Returns:
this consent

isAllowed

public boolean isAllowed()
Returns true if this object is giving permission (if the reason is null or empty.

Specified by:
isAllowed in interface Consent
See Also:
getReason()

isVetoed

public boolean isVetoed()
Returns true if this object is NOT giving permission.

Specified by:
isVetoed in interface Consent
See Also:
isAllowed()

getInteractionResult

public InteractionResult getInteractionResult()
Underlying InteractionResult that created this Consent (may be null).

Specified by:
getInteractionResult in interface Consent
Returns:
- may be null if created as a legacy Consent.

getDescription

public java.lang.String getDescription()
Description of the action allowed by this event.

(Previously, Allow consents overloaded the reason property with a description of the event. This has now been changed so that a non-null reason always implies a Veto. This property captures the description.

Specified by:
getDescription in interface Consent
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.