org.erights.e.elib.slot
Interface Guard

All Superinterfaces:
SlotGuard, ValueGuard
All Known Implementing Classes:
BaseGuard, ConstList

public interface Guard
extends SlotGuard, ValueGuard

Untamed:


Method Summary
 boolean accepts(Object specimen)
          Enabled: Would coerce(specimen, ...) succeed?
 Guard and(Guard other)
          Enabled: Coercion pipe, or function composition of guards.
 Guard butNot(Guard other)
          Enabled: (x &! y) is equivalent to (x & !y).
 Object coerce(Object specimen)
          Enabled: guard.coerce(x) should be equivalent to guard.coerce(x, null)
 Guard get()
          Enabled: guard[] should return a guard that coerces a ConstList to a ConstList in which every element has been coerced by guard.
 Slot makeSlot(Object specimen)
          Enabled: guard.makeSlot(x) should be equivalent to guard.makeSlot(x, null)
 Guard not()
          Enabled: (!x).coerce(specimen) succeeds exactly when x.coerce(specimen) fails.
 Guard or(Guard other)
          Enabled: Union type.
 Guard xor(Guard other)
          Enabled: (x ^ y) is equivalent to ((x &! y) | (!x & y)).
 
Methods inherited from interface org.erights.e.elib.slot.SlotGuard
getName, makeSlot
 
Methods inherited from interface org.erights.e.elib.slot.ValueGuard
coerce, getName
 

Method Detail

coerce

public Object coerce(Object specimen)
Enabled: guard.coerce(x) should be equivalent to guard.coerce(x, null)


accepts

public boolean accepts(Object specimen)
Enabled: Would coerce(specimen, ...) succeed?

Yes means the specimen is acceptable input to the guard, not that it is a possible output.


makeSlot

public Slot makeSlot(Object specimen)
Enabled: guard.makeSlot(x) should be equivalent to guard.makeSlot(x, null)


get

public Guard get()
Enabled: guard[] should return a guard that coerces a ConstList to a ConstList in which every element has been coerced by guard.


or

public Guard or(Guard other)
Enabled: Union type.

(x | y | z).coerce(specimen) tries x, y, and z in left to right order on specimen until one succeeds or they all fail. It yield the last outcome.

Parameters:
other -
Returns:

and

public Guard and(Guard other)
Enabled: Coercion pipe, or function composition of guards.

(x & y & z).coerce(specimen) is equivalent to

 z.coerce(y.coerce(x.coerce(specimen)))
When x and y are non-transforming guards (either failing or passing specimen through as is), then this effectively forms an intersection type.

Parameters:
other -
Returns:

not

public Guard not()
Enabled: (!x).coerce(specimen) succeeds exactly when x.coerce(specimen) fails.

(!x) is a non-transforming guard, whether or not x is.

Returns:

butNot

public Guard butNot(Guard other)
Enabled: (x &! y) is equivalent to (x & !y).

Parameters:
other -
Returns:

xor

public Guard xor(Guard other)
Enabled: (x ^ y) is equivalent to ((x &! y) | (!x & y)).

Parameters:
other -
Returns:


comments?