net.sf.asyncobjects.util
Class Condition

java.lang.Object
  extended by net.sf.asyncobjects.util.Condition

public class Condition
extends Object

This class implements some logical conditions.

Author:
const

Constructor Summary
Condition()
           
 
Method Summary
static Promise<Boolean> and(Promise<Boolean>... args)
          This operations finishes with true only if all promises resolve to true.
static Promise<Boolean> falsePromise()
           
static Promise<Boolean> not(Promise<Boolean> v)
          Logical not operation.
static Promise<Boolean> or(Promise<Boolean>... args)
          This operations finishes with false only if all promises resolve to false.
static Promise<Boolean> truePromise()
           
static Promise<Boolean> valueOf(boolean value)
          Return promise that represents a boolean value
static
<T> Promise<Boolean>
was(T expected, Promise<?> actual)
          Check if value matches expected using Object.equals(Object).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Condition

public Condition()
Method Detail

truePromise

public static Promise<Boolean> truePromise()
Returns:
a true promise.

falsePromise

public static Promise<Boolean> falsePromise()
Returns:
a false promise.

valueOf

public static Promise<Boolean> valueOf(boolean value)
Return promise that represents a boolean value

Parameters:
value - a value to wrap
Returns:
a promise

was

public static <T> Promise<Boolean> was(T expected,
                                       Promise<?> actual)
Check if value matches expected using Object.equals(Object).

Type Parameters:
T - a type of value to check
Parameters:
expected - an expected object
actual - a promise for actual value
Returns:
true if these too are equal.

not

public static Promise<Boolean> not(Promise<Boolean> v)
Logical not operation.

Parameters:
v - an promise for boolean value
Returns:
a promise for negated boolean value

and

public static Promise<Boolean> and(Promise<Boolean>... args)
This operations finishes with true only if all promises resolve to true. If one of promises resolves to false, or is smashed. The operation finishes immediatly.

Parameters:
args - argument promises
Returns:
a promise that represents result of operation.

or

public static Promise<Boolean> or(Promise<Boolean>... args)
This operations finishes with false only if all promises resolve to false. If one of promises resolves to true, or is smashed. The operation finishes immediatly.

Parameters:
args - argument promises
Returns:
a promise that represents result of operation.


Copyright 2002-2007 Constantine Plotnikov. All Rights Reserved.