org.erights.e.elib.slot
Class UnionGuard

java.lang.Object
  |
  +--org.erights.e.elib.slot.BaseGuard
        |
        +--org.erights.e.elib.slot.UnionGuard
All Implemented Interfaces:
Guard, SlotGuard, ValueGuard

public class UnionGuard
extends BaseGuard

Safe: Composes a sequence of guards to form a union type.

Since this operation is associative, we represent directly only a sequence of two. A binary tree then represents any sequence. Reports the first success or the last failure.

Author:
Mark S. Miller

Field Summary
private  ValueGuard myLeftGuard
           
private  ValueGuard myRightGuard
           
 
Fields inherited from class org.erights.e.elib.slot.BaseGuard
myOptValueGuard
 
Constructor Summary
UnionGuard(ValueGuard leftGuard, ValueGuard rightGuard)
          Enabled:
 
Method Summary
 Object coerce(Object specimen, OneArgFunc optEjector)
          Enabled:
 String getName()
          Enabled: "(leftGuard | rightGuard)[]"
 
Methods inherited from class org.erights.e.elib.slot.BaseGuard
__printOn, accepts, and, butNot, coerce, get, makeSlot, makeSlot, not, or, toString, xor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myLeftGuard

private final ValueGuard myLeftGuard

myRightGuard

private final ValueGuard myRightGuard
Constructor Detail

UnionGuard

public UnionGuard(ValueGuard leftGuard,
                  ValueGuard rightGuard)
Enabled:

Parameters:
leftGuard -
rightGuard -
Method Detail

coerce

public Object coerce(Object specimen,
                     OneArgFunc optEjector)
Enabled:

Specified by:
coerce in interface ValueGuard
Overrides:
coerce in class BaseGuard

getName

public String getName()
Enabled: "(leftGuard | rightGuard)[]"

Specified by:
getName in interface SlotGuard
Overrides:
getName in class BaseGuard


comments?