aboutsummaryrefslogtreecommitdiff
path: root/src/io/appium/droiddriver/finders/Predicates.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/io/appium/droiddriver/finders/Predicates.java')
-rw-r--r--src/io/appium/droiddriver/finders/Predicates.java83
1 files changed, 29 insertions, 54 deletions
diff --git a/src/io/appium/droiddriver/finders/Predicates.java b/src/io/appium/droiddriver/finders/Predicates.java
index f32b365..1b9ad80 100644
--- a/src/io/appium/droiddriver/finders/Predicates.java
+++ b/src/io/appium/droiddriver/finders/Predicates.java
@@ -18,17 +18,13 @@ package io.appium.droiddriver.finders;
import android.text.TextUtils;
-import java.util.Arrays;
-
import io.appium.droiddriver.UiElement;
/**
* Static utility methods pertaining to {@code Predicate} instances.
*/
public final class Predicates {
-
- private Predicates() {
- }
+ private Predicates() {}
private static final Predicate<Object> ANY = new Predicate<Object>() {
@Override
@@ -68,9 +64,9 @@ public final class Predicates {
}
/**
- * Returns a predicate that evaluates to {@code true} if both arguments evaluate to {@code true}.
- * The arguments are evaluated in order, and evaluation will be "short-circuited" as soon as a
- * false predicate is found.
+ * Returns a predicate that evaluates to {@code true} if both arguments
+ * evaluate to {@code true}. The arguments are evaluated in order, and
+ * evaluation will be "short-circuited" as soon as a false predicate is found.
*/
@SuppressWarnings("unchecked")
public static <T> Predicate<T> allOf(final Predicate<? super T> first,
@@ -96,11 +92,13 @@ public final class Predicates {
}
/**
- * Returns a predicate that evaluates to {@code true} if each of its components evaluates to
- * {@code true}. The components are evaluated in order, and evaluation will be "short-circuited"
- * as soon as a false predicate is found.
+ * Returns a predicate that evaluates to {@code true} if each of its
+ * components evaluates to {@code true}. The components are evaluated in
+ * order, and evaluation will be "short-circuited" as soon as a false
+ * predicate is found.
*/
- public static <T> Predicate<T> allOf(final Iterable<Predicate<? super T>> components) {
+ @SuppressWarnings("unchecked")
+ public static <T> Predicate<T> allOf(final Predicate<? super T>... components) {
return new Predicate<T>() {
@Override
public boolean apply(T input) {
@@ -120,21 +118,13 @@ public final class Predicates {
}
/**
- * Returns a predicate that evaluates to {@code true} if each of its components evaluates to
- * {@code true}. The components are evaluated in order, and evaluation will be "short-circuited"
- * as soon as a false predicate is found.
- */
- @SafeVarargs
- public static <T> Predicate<T> allOf(final Predicate<? super T>... components) {
- return Predicates.<T>allOf(Arrays.asList(components));
- }
-
- /**
- * Returns a predicate that evaluates to {@code true} if any one of its components evaluates to
- * {@code true}. The components are evaluated in order, and evaluation will be "short-circuited"
- * as soon as a true predicate is found.
+ * Returns a predicate that evaluates to {@code true} if any one of its
+ * components evaluates to {@code true}. The components are evaluated in
+ * order, and evaluation will be "short-circuited" as soon as a true predicate
+ * is found.
*/
- public static <T> Predicate<T> anyOf(final Iterable<Predicate<? super T>> components) {
+ @SuppressWarnings("unchecked")
+ public static <T> Predicate<T> anyOf(final Predicate<? super T>... components) {
return new Predicate<T>() {
@Override
public boolean apply(T input) {
@@ -154,18 +144,8 @@ public final class Predicates {
}
/**
- * Returns a predicate that evaluates to {@code true} if any one of its components evaluates to
- * {@code true}. The components are evaluated in order, and evaluation will be "short-circuited"
- * as soon as a true predicate is found.
- */
- @SafeVarargs
- public static <T> Predicate<T> anyOf(final Predicate<? super T>... components) {
- return Predicates.<T>anyOf(Arrays.asList(components));
- }
-
- /**
- * Returns a predicate that evaluates to {@code true} on a {@link UiElement} if its {@code
- * attribute} is {@code true}.
+ * Returns a predicate that evaluates to {@code true} on a {@link UiElement}
+ * if its {@code attribute} is {@code true}.
*/
public static Predicate<UiElement> attributeTrue(final Attribute attribute) {
return new Predicate<UiElement>() {
@@ -183,8 +163,8 @@ public final class Predicates {
}
/**
- * Returns a predicate that evaluates to {@code true} on a {@link UiElement} if its {@code
- * attribute} is {@code false}.
+ * Returns a predicate that evaluates to {@code true} on a {@link UiElement}
+ * if its {@code attribute} is {@code false}.
*/
public static Predicate<UiElement> attributeFalse(final Attribute attribute) {
return new Predicate<UiElement>() {
@@ -202,8 +182,8 @@ public final class Predicates {
}
/**
- * Returns a predicate that evaluates to {@code true} on a {@link UiElement} if its {@code
- * attribute} equals {@code expected}.
+ * Returns a predicate that evaluates to {@code true} on a {@link UiElement}
+ * if its {@code attribute} equals {@code expected}.
*/
public static Predicate<UiElement> attributeEquals(final Attribute attribute,
final Object expected) {
@@ -222,11 +202,10 @@ public final class Predicates {
}
/**
- * Returns a predicate that evaluates to {@code true} on a {@link UiElement} if its {@code
- * attribute} matches {@code regex}.
+ * Returns a predicate that evaluates to {@code true} on a {@link UiElement}
+ * if its {@code attribute} matches {@code regex}.
*/
- public static Predicate<UiElement> attributeMatches(final Attribute attribute,
- final String regex) {
+ public static Predicate<UiElement> attributeMatches(final Attribute attribute, final String regex) {
return new Predicate<UiElement>() {
@Override
public boolean apply(UiElement element) {
@@ -242,8 +221,8 @@ public final class Predicates {
}
/**
- * Returns a predicate that evaluates to {@code true} on a {@link UiElement} if its {@code
- * attribute} contains {@code substring}.
+ * Returns a predicate that evaluates to {@code true} on a {@link UiElement}
+ * if its {@code attribute} contains {@code substring}.
*/
public static Predicate<UiElement> attributeContains(final Attribute attribute,
final String substring) {
@@ -261,8 +240,7 @@ public final class Predicates {
};
}
- public static Predicate<UiElement> withParent(
- final Predicate<? super UiElement> parentPredicate) {
+ public static Predicate<UiElement> withParent(final Predicate<? super UiElement> parentPredicate) {
return new Predicate<UiElement>() {
@Override
public boolean apply(UiElement element) {
@@ -299,8 +277,7 @@ public final class Predicates {
};
}
- public static Predicate<UiElement> withSibling(
- final Predicate<? super UiElement> siblingPredicate) {
+ public static Predicate<UiElement> withSibling(final Predicate<? super UiElement> siblingPredicate) {
return new Predicate<UiElement>() {
@Override
public boolean apply(UiElement element) {
@@ -341,6 +318,4 @@ public final class Predicates {
}
};
}
-
-
}