com.atlassian.pageobjects.elements.query
Class Conditions

java.lang.Object
  extended by com.atlassian.pageobjects.elements.query.Conditions

public final class Conditions
extends Object

Utilities to create miscellaneous TimedConditions.


Nested Class Summary
static interface Conditions.CombinableCondition
          A timed condition that may be logically combined with others, by means of basic logical operations: 'and'/'or'.
 
Method Summary
static TimedCondition alwaysFalse()
          A timed condition that always returns false
static TimedCondition alwaysTrue()
          A timed condition that always returns true
static Conditions.CombinableCondition and(Iterable<TimedQuery<Boolean>> conditions)
           Return new combinable condition that is logical product of conditions.
static Conditions.CombinableCondition and(TimedQuery<Boolean>... conditions)
           Return new combinable condition that is logical product of conditions.
static TimedCondition dependantCondition(TimedQuery<Boolean> original, com.google.common.base.Supplier<TimedQuery<Boolean>> dependant)
           Returns a condition that combines original and dependant in a manner that dependant condition will only ever be retrieved if the original condition is true.
static
<T> TimedCondition
forMatcher(TimedQuery<T> query, org.hamcrest.Matcher<? super T> matcher)
           Return condition that will be true, if given matcher will match the query.
static TimedCondition forSupplier(long defaultTimeout, com.google.common.base.Supplier<Boolean> supplier)
          Returns a timed condition, whose current evaluation is based on a value provided by given supplier.
static TimedCondition forSupplier(com.google.common.base.Supplier<Boolean> supplier)
          Returns a timed condition, whose current evaluation is based on a value provided by given supplier.
static TimedCondition forSupplier(Timeouts timeouts, com.google.common.base.Supplier<Boolean> supplier)
          Returns a timed condition, whose current evaluation is based on a value provided by given supplier.
static
<T> TimedCondition
isEqual(T value, TimedQuery<T> query)
          Returns timed condition verifying that given query will evaluate to value equal to value.
static TimedQuery<Boolean> not(TimedQuery<Boolean> condition)
          Return new timed condition that is a negation of condition.
static Conditions.CombinableCondition or(Iterable<TimedQuery<Boolean>> conditions)
           Return new combinable condition that is logical sum of conditions.
static Conditions.CombinableCondition or(TimedQuery<Boolean>... conditions)
           Return new combinable condition that is logical sum of conditions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

not

public static TimedQuery<Boolean> not(TimedQuery<Boolean> condition)
Return new timed condition that is a negation of condition.

Parameters:
condition - condition to be negated
Returns:
negated TimedCondition instance.

and

public static Conditions.CombinableCondition and(TimedQuery<Boolean>... conditions)

Return new combinable condition that is logical product of conditions.

The resulting condition will have interval of the first condition in the conditions array,

Parameters:
conditions - conditions to conjoin
Returns:
product of conditions
Throws:
IllegalArgumentException - if conditions array is null or empty
See Also:
PollingQuery.interval()

and

public static Conditions.CombinableCondition and(Iterable<TimedQuery<Boolean>> conditions)

Return new combinable condition that is logical product of conditions.

The resulting condition will have interval of the first condition in the conditions array,

Parameters:
conditions - conditions to conjoin
Returns:
product of conditions
Throws:
IllegalArgumentException - if conditions array is null or empty
See Also:
PollingQuery.interval()

or

public static Conditions.CombinableCondition or(TimedQuery<Boolean>... conditions)

Return new combinable condition that is logical sum of conditions.

The resulting condition will have interval of the first condition in the conditions array,

Parameters:
conditions - conditions to sum
Returns:
logical sum of conditions
Throws:
IllegalArgumentException - if conditions array is null or empty
See Also:
PollingQuery.interval()

or

public static Conditions.CombinableCondition or(Iterable<TimedQuery<Boolean>> conditions)

Return new combinable condition that is logical sum of conditions.

The resulting condition will have interval of the first condition in the conditions array,

Parameters:
conditions - conditions to sum
Returns:
logical sum of conditions
Throws:
IllegalArgumentException - if conditions array is null or empty
See Also:
PollingQuery.interval()

dependantCondition

public static TimedCondition dependantCondition(TimedQuery<Boolean> original,
                                                com.google.common.base.Supplier<TimedQuery<Boolean>> dependant)

Returns a condition that combines original and dependant in a manner that dependant condition will only ever be retrieved if the original condition is true. This is useful when dependant condition may only be retrieved given the original condition is true.

The supplier for dependant condition is allowed to return null or throw exception if the original condition returns false. But it may not do so given the original condition is true, as this will lead to NullPointerException or the raised exception be propagated by this condition respectively.

Parameters:
original - original condition
dependant - supplier for dependant condition that will only be evaluated given the original condition evaluates to true
Returns:
new dependant condition

forMatcher

public static <T> TimedCondition forMatcher(TimedQuery<T> query,
                                            org.hamcrest.Matcher<? super T> matcher)

Return condition that will be true, if given matcher will match the query. Any Hamcrest matcher implementation may be used.

Example:
TimedCondition textEquals = Conditions.forMatcher(element.getText(), isEqualTo("blah"));

Type Parameters:
T - type of the result
Parameters:
query - timed query to match
matcher - matcher for the query
Returns:
new matching condition

isEqual

public static <T> TimedCondition isEqual(T value,
                                         TimedQuery<T> query)
Returns timed condition verifying that given query will evaluate to value equal to value. The timeouts are inherited from the provided query

Type Parameters:
T - type of the value
Parameters:
value - value that query should be equalt to
query - the timed query
Returns:
timed condition for query equality to value

forSupplier

public static TimedCondition forSupplier(com.google.common.base.Supplier<Boolean> supplier)
Returns a timed condition, whose current evaluation is based on a value provided by given supplier.

Parameters:
supplier - supplier of the current condition value
Returns:
new query based on supplier

forSupplier

public static TimedCondition forSupplier(long defaultTimeout,
                                         com.google.common.base.Supplier<Boolean> supplier)
Returns a timed condition, whose current evaluation is based on a value provided by given supplier.

Parameters:
defaultTimeout - default timeout of the condition
supplier - supplier of the current condition value
Returns:
new query based on supplier

forSupplier

public static TimedCondition forSupplier(Timeouts timeouts,
                                         com.google.common.base.Supplier<Boolean> supplier)
Returns a timed condition, whose current evaluation is based on a value provided by given supplier.

Parameters:
timeouts - an instance of timeouts to use for the new condition
supplier - supplier of the current condition value
Returns:
new query based on supplier

alwaysTrue

public static TimedCondition alwaysTrue()
A timed condition that always returns true

Returns:
timed condition that always returns true

alwaysFalse

public static TimedCondition alwaysFalse()
A timed condition that always returns false

Returns:
timed condition that always returns false


Copyright © 2014 Atlassian. All rights reserved.