Java 类android.support.test.espresso.core.deps.guava.base.Predicate 实例源码

项目:AndroidSnooper    文件:SnooperRepoTest.java   
private Matcher<? super List<HttpHeaderValue>> containsWithValue(final String value) {
  return new CustomTypeSafeMatcher<List<HttpHeaderValue>>("contains with value:" + value) {
    @Override
    protected boolean matchesSafely(List<HttpHeaderValue> list) {
      return any(list, new Predicate<HttpHeaderValue>() {
        @Override
        public boolean apply(@Nullable HttpHeaderValue httpHeaderValue) {
          return httpHeaderValue.getValue().equals(value);
        }
      });
    }
  };
}
项目:americano    文件:RelativeMatcher.java   
private RelativeMatcher(Matcher<View> target, DoublePredicate<View> predicate, String description, Type type) {
    mTarget = target;
    mTargetPredicate = new Predicate<View>() {
        @Override
        public boolean apply(@Nullable View view) {
            return mTarget.matches(view);
        }
    };
    mPredicate = predicate;
    mDescription = description;
    mType = type;
}
项目:americano    文件:RelativeMatcher.java   
@Override
public boolean matchesSafely(final View testView) {
    if (!mTargetPredicate.apply(testView))
        return false;

    Predicate<View> pred = new Predicate<View>() {
        @Override
        public boolean apply(@Nullable View targetView) {
            return mPredicate.apply(testView, targetView);
        }
    };
    Iterable<View> traversal = Iterables.filter(breadthFirstViewTraversal(testView.getRootView()), new Predicate<View>() {
        @Override
        public boolean apply(@Nullable View input) {
            return input != testView && mTargetPredicate.apply(input);
        }
    });
    if (Iterables.isEmpty(traversal)) {
        throw new NoMatchingViewException.Builder().withViewMatcher(mTarget).build(); // TODO: build an actual err msg
    }
    switch (mType) {
        case ANY:   return Iterables.any(traversal, pred);
        case ALL:   return Iterables.all(traversal, pred);
        case NONE:  return !Iterables.any(traversal, pred);
        default:    throw new IllegalStateException("impossible mType");
    }
}