Guava Predicate - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava Predicate class.

This code example shows how to use the following methods:apply
    public static final KeySelector of(int limit) {
        return new KeySelector(Predicates.<StaticBuffer>alwaysTrue(), limit);
    } 
 
    public boolean include(StaticBuffer key) {
        if (keyFilter.apply(key)) {
            count++;
            return true; 
        } else return false; 
    } 
 
    public boolean reachedLimit() { 
        if (count >= limit) return true;
        else return false; 
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:apply
      Predicates2.startsWith("---- BEGIN SSH2 PUBLIC KEY ----")); 
 
   @Override 
   public String apply(Object from) {
      String fromString = checkNotNull(from, "input").toString();
      checkArgument(ALLOWED_MARKERS.apply(fromString), "must be a ssh public key, conforming to %s ", ALLOWED_MARKERS);
      return base64().encode(fromString.getBytes(UTF_8));
   } 
} 
6
CodeRank
This code example shows how to use the following methods:apply
         public boolean apply(Integer value) {
            return domainApi.list().size() == value.intValue();
         } 
      }, 30, 1, SECONDS);
 
      assertTrue(result.apply(before + 1));
   } 
 
} 
6
CodeRank
This code example shows how to use the following methods:hashCode
        assertNotEquals(predicate, duplicate);
        assertNotEquals(duplicate, predicate);
    } 
 
    @Test public void hashCodeBasedOnIdentity() {
        assertEquals(System.identityHashCode(predicate), predicate.hashCode());
    } 
 
    @Test public void toStringGivesAnIndicationOfItsRandomGeneration() {
        assertEquals("a randomly generated instance of " + Predicate.class, predicate.toString());
    } 
 
    @Test public void rejectsNonFunctionalInterface() {
        thrown.expect(IllegalArgumentException.class);
        thrown.expectMessage(Cloneable.class + " is not a functional interface");
 
        makeLambda(Cloneable.class, new TestIntegerGenerator(), null); 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:apply
 
    @Override 
    public void report( 
            @NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location 
    ) { 
        if (!decline.apply(severity)) { 
            messageCollector.report(severity, message, location); 
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:apply
    * @return result of the job's execution 
    * @throws ExecutionException 
    *            if the job contained an error 
    */ 
   public <T> T apply(AsyncCreateResponse job) {
      boolean completed = jobComplete.apply(job.getJobId());
      logger.trace("<< job(%s) complete(%s)", job, completed);
      AsyncJob<T> jobWithResult = client.getAsyncJobApi().<T> getAsyncJob(job.getJobId());
      checkState(completed, "job %s failed to complete in time %s", job.getJobId(), jobWithResult);
      if (jobWithResult.getError() != null)
         throw new UncheckedExecutionException(String.format("job %s failed with exception %s", job.getJobId(),
               jobWithResult.getError().toString())) {
         }; 
      return jobWithResult.getResult();
   } 
} 
6
CodeRank
This code example shows how to use the following methods:apply
        return filter(m) ? m : null;
    } 
 
    protected boolean filter(M m) {
        if (p != null)
            return p.apply(m);
        throw new UnsupportedOperationException();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:apply
 
   @Override 
   public SecurityGroupInRegion load(RegionAndName in) {
      AtomicReference<RegionAndName> securityGroupInRegionRef = Atomics.newReference(checkNotNull(in,
               "regionSecurityGroupNameAndPorts")); 
      if (returnSecurityGroupExistsInRegion.apply(securityGroupInRegionRef)) {
         return returnExistingSecurityGroup(securityGroupInRegionRef);
      } else { 
         return createNewSecurityGroup(in);
      } 
   } 
 
   private SecurityGroupInRegion returnExistingSecurityGroup(AtomicReference<RegionAndName> securityGroupInRegionRef) {
      RegionAndName securityGroupInRegion = securityGroupInRegionRef.get();
      checkState(securityGroupInRegion instanceof SecurityGroupInRegion,
               "programming error: predicate %s should update the atomic reference to the actual security group found", 
               returnSecurityGroupExistsInRegion);
      return SecurityGroupInRegion.class.cast(securityGroupInRegion);
   } 
 
6
CodeRank
This code example shows how to use the following methods:apply
        return filter(m) ? m : null;
    } 
 
    protected boolean filter(M m) {
        if (p != null)
            return p.apply(m);
        throw new UnsupportedOperationException();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:apply
      Task task = client.resetVApp(URI.create(checkNotNull(in, "node.id")));
      return returnWhenTaskCompletes(in, task);
   } 
 
   private NodeMetadata returnWhenTaskCompletes(String in, Task task) {
      taskTester.apply(task.getHref());
      return getNode.getNode(in);
   } 
 
   @Override 
   public NodeMetadata resumeNode(String in) {
      Task task = client.powerOnVApp(URI.create(checkNotNull(in, "node.id")));
      return returnWhenTaskCompletes(in, task);
   } 
 
   @Override 
   public NodeMetadata suspendNode(String in) {
      Task task = client.powerOffVApp(URI.create(checkNotNull(in, "node.id")));
      return returnWhenTaskCompletes(in, task);
   } 
6
CodeRank
See Code Examples for Guava Predicate Methods: