Package com.google.common.base

Examples of com.google.common.base.Predicate.apply()


        // given
        Predicate elevenInCollectionPredicate = Predicates.in(Arrays.asList(11L, 22L, 33L, 44L));

        // then
        assertThat(elevenInCollectionPredicate.apply(11L)).isTrue();
    }

   
}
View Full Code Here


    Set<String> timeFields = Sets.newHashSet();
    int i = 0;
    for (FieldPartitioner fp : strategy.getFieldPartitioners()) {
      String partition = fp.getName();
      Predicate partitionPredicate = unsatisfied.get(partition);
      if (partitionPredicate != null && partitionPredicate.apply(key.get(i))) {
        unsatisfied.remove(partition);
        LOG.debug("removing " + partition + " satisfied by " + key.get(i));
      }

      String source = fp.getSourceName();
View Full Code Here

      // remove the field if it is satisfied by the StorageKey
      Predicate original = unsatisfied.get(source);
      if (original != null) {
        Predicate isSatisfiedBy = fp.projectStrict(original);
        LOG.debug("original: " + original + ", strict: " + isSatisfiedBy);
        if ((isSatisfiedBy != null) && isSatisfiedBy.apply(key.get(i))) {
          LOG.debug("removing " + source + " satisfied by " + key.get(i));
          unsatisfied.remove(source);
        }
      }
      i += 1;
View Full Code Here

      Predicate<Long> original = unsatisfied.get(timeField);
      if (original != null) {
        Predicate<Marker> isSatisfiedBy = TimeDomain.get(strategy, timeField)
            .projectStrict(original);
        LOG.debug("original: " + original + ", strict: " + isSatisfiedBy);
        if ((isSatisfiedBy != null) && isSatisfiedBy.apply(key)) {
          LOG.debug("removing " + timeField + " satisfied by " + key);
          unsatisfied.remove(timeField);
        }
      }
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void checkContained(String name, Object... values) {
    for (Object value : values) {
      if (constraints.containsKey(name)) {
        Predicate current = constraints.get(name);
        Preconditions.checkArgument(current.apply(value),
            "%s does not match %s", current, value);
      }
    }
  }
View Full Code Here

    @Test
    public void testClassify() {
        Predicate predicate = Mockito.mock(Predicate.class);
        PredicateBinaryExceptionClassifier classifier = new PredicateBinaryExceptionClassifier(predicate);
        classifier.setPredicate(predicate);
        Mockito.when(predicate.apply(Mockito.any(Throwable.class))).thenReturn(false);
        Assert.assertSame(predicate, classifier.getPredicate());
        Assert.assertFalse(classifier.classify(new RuntimeException()));
        Mockito.verify(predicate, Mockito.times(1)).apply(Mockito.any(Throwable.class));
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.