|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jutil.java.collections.BooleanAccumulator | +--org.jutil.java.collections.ForAll
A boolean for-all operator.
A convenience accumulator of collections that checks whether all
elements of a collection satisfy the criterion defined in the abstract
method public boolean criterion(Object element)
.
As with Accumulator
, this class can best be used as an anonymous
inner class.
boolean bool =
new ForAll() {
/oo
o also public behavior
o
o post (* additional precondition for criterion method *)
o
o public model boolean isValidElement(Object element);
o/
/oo
o also public behavior
o
o post \result == ((MyType)element.someProperty() ...)
o/
public boolean criterion(Object element) {
// criterion code
}
}.in(collection);
Field Summary | |
static java.lang.String |
CVS_REVISION
|
Constructor Summary | |
ForAll()
|
Method Summary | |
boolean |
accumulate(java.lang.Object element,
boolean acc)
also public behavior post \result == (acc && criterion(element)); |
abstract boolean |
criterion(java.lang.Object element)
public behavior pre isValidElement(element); // criterion should be consistent with equals; subclass can say more post (\forall object o1;; (\forall object o2; o2.equals(o1); criterion(o1) == criterion(o2))); Check whether the given object satisfies the criterion for this ForAll accumulator. |
boolean |
in(java.util.Collection collection)
also public behavior post \result == (\forall Object o; collection.contains(o); criterion(o)); |
boolean |
initialAccumulator()
also public behavior post \result == true; |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String CVS_REVISION
Constructor Detail |
public ForAll()
Method Detail |
public abstract boolean criterion(java.lang.Object element)
public final boolean initialAccumulator()
initialAccumulator
in class BooleanAccumulator
public final boolean accumulate(java.lang.Object element, boolean acc)
accumulate
in class BooleanAccumulator
org.jutil.java.collections.BooleanAccumulator
element
- The object the method will process and change the accumulator with.acc
- The accumulator for the accumulation.
For the first element to be processed, the result of initialAccumulator
is used. For the other elements, the result of this method applied on
the previous element is used.public boolean in(java.util.Collection collection)
in
in class BooleanAccumulator
org.jutil.java.collections.BooleanAccumulator
collection
- The collection for which the ForAll operator has to be computed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |