org.erights.e.elib.slot
Class BaseGuard

java.lang.Object
  |
  +--org.erights.e.elib.slot.BaseGuard
All Implemented Interfaces:
Guard, SlotGuard, ValueGuard
Direct Known Subclasses:
AnyGuard, BaseAuditor, FinalGuard, ListGuard, MapGuard, NullOkGuard, PassByProxyGuard, SettableGuard, TupleGuard, UnionGuard, VoidGuard

public class BaseGuard
extends Object
implements Guard

Safe:

Author:
Mark S. Miller

Field Summary
protected  ValueGuard myOptValueGuard
           
 
Constructor Summary
BaseGuard()
          Enabled: If you override coerce/2 in a subclass, call this constructor in order to effectively provide "this" as an argument.
BaseGuard(ValueGuard optValueGuard)
          Enabled: Provide a non-null optValueGuard to provide an explicit object to be used as the optional ValueGuard.
 
Method Summary
 void __printOn(TextWriter out)
          Enabled: Same as "<" + getName() + ">".
 boolean accepts(Object specimen)
          Enabled:
 Guard and(Guard other)
          Enabled:
 Guard butNot(Guard other)
          Enabled:
 Object coerce(Object specimen)
          Enabled:
 Object coerce(Object specimen, OneArgFunc optEjector)
          Enabled: Returns specimen as coerced through the optional valueGuard.
 Guard get()
          Enabled:
 String getName()
          Enabled: "settable" or "settable(value-guard-name)".
 Slot makeSlot(Object specimen)
          Enabled:
 Slot makeSlot(Object specimen, OneArgFunc optEjector)
          Enabled: Returns a settable slot that coerces specimens (including the initial value) through the optional valueGuard.
 Guard not()
          Enabled:
 Guard or(Guard other)
          Enabled:
 String toString()
          Suppressed: Same as getName()
 Guard xor(Guard other)
          Enabled:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myOptValueGuard

protected final ValueGuard myOptValueGuard
Constructor Detail

BaseGuard

public BaseGuard(ValueGuard optValueGuard)
Enabled: Provide a non-null optValueGuard to provide an explicit object to be used as the optional ValueGuard.

In the latter case, your overriding coerce/2 method should not call super.coerce/2. Likewise with getName/0.

Call this with null to indicate the indentity coercion.


BaseGuard

public BaseGuard()
Enabled: If you override coerce/2 in a subclass, call this constructor in order to effectively provide "this" as an argument.

Method Detail

getName

public String getName()
Enabled: "settable" or "settable(value-guard-name)".

Specified by:
getName in interface SlotGuard

coerce

public Object coerce(Object specimen,
                     OneArgFunc optEjector)
Enabled: Returns specimen as coerced through the optional valueGuard.

Specified by:
coerce in interface ValueGuard

coerce

public Object coerce(Object specimen)
Enabled:

Specified by:
coerce in interface Guard
Parameters:
specimen -
Returns:

accepts

public boolean accepts(Object specimen)
Enabled:

Specified by:
accepts in interface Guard

makeSlot

public Slot makeSlot(Object specimen,
                     OneArgFunc optEjector)
Enabled: Returns a settable slot that coerces specimens (including the initial value) through the optional valueGuard.

Specified by:
makeSlot in interface SlotGuard

makeSlot

public Slot makeSlot(Object specimen)
Enabled:

Specified by:
makeSlot in interface Guard
Parameters:
specimen -
Returns:

get

public Guard get()
Enabled:

Specified by:
get in interface Guard
Returns:

or

public Guard or(Guard other)
Enabled:

Specified by:
or in interface Guard
Parameters:
other -
Returns:

and

public Guard and(Guard other)
Enabled:

Specified by:
and in interface Guard
Parameters:
other -
Returns:

not

public Guard not()
Enabled:

Specified by:
not in interface Guard
Returns:

butNot

public Guard butNot(Guard other)
Enabled:

Specified by:
butNot in interface Guard
Parameters:
other -
Returns:

xor

public Guard xor(Guard other)
Enabled:

Specified by:
xor in interface Guard
Parameters:
other -
Returns:

toString

public String toString()
Suppressed: Same as getName()

Overrides:
toString in class Object
Returns:
a string representation of the object.

__printOn

public void __printOn(TextWriter out)
               throws IOException
Enabled: Same as "<" + getName() + ">".

IOException


comments?