List of usage examples for com.google.common.base Predicates equalTo
public static <T> Predicate<T> equalTo(@Nullable T target)
From source file:org.sosy_lab.cpachecker.util.expressions.And.java
public static <LeafType> ExpressionTree<LeafType> of(Iterable<ExpressionTree<LeafType>> pOperands) { // If one of the operands is false, return false if (Iterables.contains(pOperands, ExpressionTrees.getFalse())) { return ExpressionTrees.getFalse(); }//from w w w . j ava 2 s . c o m // Filter out trivial operands and flatten the hierarchy ImmutableSet<ExpressionTree<LeafType>> operands = FluentIterable.from(pOperands) .filter(Predicates.not(Predicates.equalTo(ExpressionTrees.<LeafType>getTrue()))) .transformAndConcat(new Function<ExpressionTree<LeafType>, Iterable<ExpressionTree<LeafType>>>() { @Override public Iterable<ExpressionTree<LeafType>> apply(ExpressionTree<LeafType> pOperand) { if (pOperand instanceof And) { return (And<LeafType>) pOperand; } return Collections.singleton(pOperand); } }).toSet(); // If there are no operands, return the neutral element if (operands.isEmpty()) { return ExpressionTrees.getTrue(); } // If there is only one operand, return it if (operands.size() == 1) { return operands.iterator().next(); } return new And<>(operands); }
From source file:brooklyn.entity.basic.EntityPredicates.java
public static Predicate<Entity> displayNameEqualTo(final String val) { return displayNameSatisfies(Predicates.equalTo(val)); }
From source file:com.intellij.packaging.impl.elements.moduleContent.ModuleOutputElementTypeBase.java
public boolean isSuitableModule(ModulesProvider modulesProvider, Module module) { for (ContentEntry entry : modulesProvider.getRootModel(module).getContentEntries()) { if (entry.getFolders(Predicates.equalTo(myContentFolderTypeProvider)).length != 0) { return true; }//from w w w . j a va2 s . co m } return false; }
From source file:org.apache.cassandra.cql3.statements.SchemaAlteringStatement.java
private static Map<String, List<String>> describeSchemaVersions() { // unreachable hosts don't count towards disagreement return Maps.filterKeys(StorageProxy.describeSchemaVersions(), Predicates.not(Predicates.equalTo(StorageProxy.UNREACHABLE))); }
From source file:com.replaymod.replaystudio.pathing.change.AddKeyframe.java
@Override public void apply(Timeline timeline) { Preconditions.checkState(!applied, "Already applied!"); Path path = timeline.getPaths().get(this.path); Keyframe keyframe = path.insert(time); index = Iterables.indexOf(path.getKeyframes(), Predicates.equalTo(keyframe)); applied = true;/* ww w.j a va 2s . co m*/ }
From source file:com.google.gerrit.server.notedb.RepoSequence.java
@VisibleForTesting static RetryerBuilder<RefUpdate.Result> retryerBuilder() { return RetryerBuilder.<RefUpdate.Result>newBuilder() .retryIfResult(Predicates.equalTo(RefUpdate.Result.LOCK_FAILURE)) .withWaitStrategy(WaitStrategies.join(WaitStrategies.exponentialWait(5, TimeUnit.SECONDS), WaitStrategies.randomWait(50, TimeUnit.MILLISECONDS))) .withStopStrategy(StopStrategies.stopAfterDelay(30, TimeUnit.SECONDS)); }
From source file:net.automatalib.util.automata.predicates.TransitionPredicates.java
public static <S, I, T> TransitionPredicate<S, I, T> inputIs(Object input) { return inputSatisfying(Predicates.equalTo(input)); }
From source file:org.netbeans.modules.android.project.configs.ConfigGroup.java
public void updateCurrentConfig(Config config) { int idx = Iterables.indexOf(configs, Predicates.equalTo(currentConfig)); if (idx >= 0) { configs.set(idx, config);/*from w ww . ja v a 2 s . com*/ } }
From source file:brooklyn.entity.basic.EntityTasks.java
/** as {@link #requiringAttributeEventually(Entity, AttributeSensor, Predicate, Duration) for multiple entities */ public static <T> Task<Boolean> requiringAttributeEventually(Iterable<Entity> entities, AttributeSensor<T> sensor, Predicate<T> condition, Duration timeout) { return DependentConfiguration.builder().attributeWhenReadyFromMultiple(entities, sensor, condition) .postProcess(Functions.constant(true)).timeout(timeout).onTimeoutThrow().onUnmanagedThrow() .postProcessFromMultiple(CollectionFunctionals.all(Predicates.equalTo(true))).build(); }
From source file:org.graylog2.buffers.Buffers.java
public void waitForEmptyBuffers(final long maxWait, final TimeUnit timeUnit) { LOG.info("Waiting until all buffers are empty."); final Callable<Boolean> checkForEmptyBuffers = new Callable<Boolean>() { @Override/*from w w w.j av a2s . c o m*/ public Boolean call() throws Exception { if (processBuffer.isEmpty() && outputBuffer.isEmpty()) { return true; } else { LOG.info("Waiting for buffers to drain. ({}p/{}o)", processBuffer.getUsage(), outputBuffer.getUsage()); } return false; } }; final Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder() .retryIfResult(Predicates.not(Predicates.equalTo(Boolean.TRUE))) .withWaitStrategy(WaitStrategies.fixedWait(1, TimeUnit.SECONDS)) .withStopStrategy(StopStrategies.stopAfterDelay(maxWait, timeUnit)).build(); try { retryer.call(checkForEmptyBuffers); } catch (RetryException e) { LOG.info("Buffers not empty after {} {}. Giving up.", maxWait, timeUnit.name().toLowerCase(Locale.ENGLISH)); return; } catch (ExecutionException e) { LOG.error("Error while waiting for empty buffers.", e); return; } LOG.info("All buffers are empty. Continuing."); }