List of usage examples for com.google.common.base Predicates equalTo
public static <T> Predicate<T> equalTo(@Nullable T target)
From source file:org.eclipse.sirius.diagram.ui.tools.internal.figure.locator.FeedbackDBorderItemLocator.java
@Override protected List<IFigure> getBrotherFigures(IFigure targetBorderItem) { IFigure parentFigure = getParentFigure(); if (parentFigure instanceof BorderedNodeFigure) { parentFigure = ((BorderedNodeFigure) parentFigure).getBorderItemContainer(); }/*from w ww . ja v a 2s . c om*/ @SuppressWarnings("unchecked") Iterable<IFigure> brotherFigures = Iterables.filter(parentFigure.getChildren(), Predicates .and(Predicates.instanceOf(IFigure.class), Predicates.not(Predicates.equalTo(targetBorderItem)))); return Lists.newArrayList(brotherFigures); }
From source file:com.twitter.aurora.scheduler.filter.AttributeFilter.java
/** * Tests whether an attribute matches a limit constraint. * * @param attributes Attributes to match against. * @param jobKey Key of the job with the limited constraint. * @param limit Limit value./* www .j a v a2 s. c o m*/ * @param activeTasks All active tasks in the system. * @param attributeFetcher Interface for fetching attributes for hosts in the system. * @return {@code true} if the limit constraint is satisfied, {@code false} otherwise. */ static boolean matches(final Set<Attribute> attributes, final IJobKey jobKey, int limit, Iterable<IScheduledTask> activeTasks, final AttributeLoader attributeFetcher) { Predicate<IScheduledTask> sameJob = Predicates.compose(Predicates.equalTo(jobKey), Tasks.SCHEDULED_TO_JOB_KEY); Predicate<IScheduledTask> hasAttribute = new Predicate<IScheduledTask>() { @Override public boolean apply(IScheduledTask task) { Iterable<Attribute> hostAttributes = attributeFetcher.apply(task.getAssignedTask().getSlaveHost()); return Iterables.any(hostAttributes, Predicates.in(attributes)); } }; return limit > Iterables.size(Iterables.filter(activeTasks, Predicates.and(sameJob, hasAttribute))); }
From source file:com.google.caliper.config.CaliperConfigLoader.java
private static ImmutableMap<String, String> mergeProperties(Map<String, String> commandLine, Map<String, String> user, Map<String, String> defaults) { Map<String, String> map = Maps.newHashMap(defaults); map.putAll(user); // overwrite and augment map.putAll(commandLine); // overwrite and augment Iterables.removeIf(map.values(), Predicates.equalTo("")); return ImmutableMap.copyOf(map); }
From source file:com.twitter.aurora.scheduler.storage.mem.MemUpdateStore.java
private static Predicate<JobUpdateConfiguration> hasRole(String role) { checkNotNull(role); return Predicates.compose(Predicates.equalTo(role), GET_ROLE); }
From source file:com.facebook.presto.connector.system.jdbc.FilterUtil.java
public static <T> Iterable<T> filter(Iterable<T> items, Optional<T> filter) { if (!filter.isPresent()) { return items; }/*from w ww.j av a 2 s.c om*/ return Iterables.filter(items, Predicates.equalTo(filter.get())); }
From source file:io.appform.nautilus.funnel.sessionmanagement.SessionActivityHandler.java
public SessionActivityHandler(ESTemporalTypedEntityStore store) { this.store = store; retryer = RetryerBuilder.<Boolean>newBuilder().retryIfResult(Predicates.equalTo(false)) .withStopStrategy(StopStrategies.stopAfterAttempt(RETRY_ATTEMPTS)).build(); }
From source file:io.dropwizard.discovery.bundle.id.NodeIdManager.java
public int fixNodeId() { try {//from w w w. j a va 2 s . c o m log.info("Waiting for curator to start"); curatorFramework.blockUntilConnected(); log.info("Curator started"); } catch (InterruptedException e) { log.error("Wait for curator start interrupted", e); } Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder().retryIfResult(Predicates.equalTo(false)) .retryIfException().withStopStrategy(StopStrategies.neverStop()).build(); try { retryer.call(() -> { node = secureRandom.nextInt(Constants.MAX_NUM_NODES); final String path = pathUtils.path(node); try { curatorFramework.create().creatingParentContainersIfNeeded().withMode(CreateMode.EPHEMERAL) .forPath(path); } catch (KeeperException.NodeExistsException e) { log.warn("Collision on node {}, will retry with new node.", node); return false; } log.info("Node will be set to node id {}", node); return true; }); } catch (RetryException e) { log.error("Error creating node", e); } catch (ExecutionException e) { log.error("Execution exception while creating node", e); } return node; }
From source file:io.brooklyn.ambari.AmbariLiveTestHelper.java
protected void assertHadoopClusterEventuallyDeployed(Application app) { AmbariServer ambariServer = Entities.descendants(app, AmbariServer.class).iterator().next(); EntityTestUtils.assertAttributeEventually(ImmutableMap.of("timeout", Duration.minutes(60)), ambariServer, AmbariServer.CLUSTER_STATE, Predicates.not(Predicates.or(Predicates.equalTo("ABORTED"), Predicates.equalTo("FAILED"), Predicates.equalTo("TIMEDOUT")))); EntityTestUtils.assertAttributeEventually(ImmutableMap.of("timeout", Duration.minutes(60)), ambariServer, AmbariServer.CLUSTER_STATE, Predicates.equalTo("COMPLETED")); }
From source file:net.automatalib.util.graphs.ShortestPaths.java
public static <N, E> Iterable<Path<N, E>> shortestPaths(IndefiniteGraph<N, E> graph, Collection<? extends N> start, int limit, N target) { return shortestPaths(graph, start, limit, Predicates.equalTo(target)); }
From source file:tile80.world80.World80HOF.java
@Override public Tile80 getTileById(String Symbol) { return FluentIterable.from(world).filter(Predicates.compose(Predicates.equalTo(Symbol), onlyId)).first() .or(Tile80.nothing); }