@GwtIncompatible // SerializableTester public void testForPredicateSerializable() { checkCanReserialize(Functions.forPredicate(Predicates.equalTo(5))); }
public void testForPredicate() { Function<Object, Boolean> alwaysTrue = Functions.forPredicate(Predicates.alwaysTrue()); Function<Object, Boolean> alwaysFalse = Functions.forPredicate(Predicates.alwaysFalse()); assertTrue(alwaysTrue.apply(0)); assertFalse(alwaysFalse.apply(0)); new EqualsTester() .addEqualityGroup(alwaysTrue, Functions.forPredicate(Predicates.alwaysTrue())) .addEqualityGroup(alwaysFalse) .addEqualityGroup(Functions.identity()) .testEquals(); }
public static <T> Pair<Collection<T>,Collection<T>> partition(Iterator<T> iterator, Predicate<? super T> predicate) { Multimap<Boolean,T> map = Multimaps.index(iterator, com.google.common.base.Functions.forPredicate(predicate)); return new Pair<Collection<T>,Collection<T>>(map.get(true), map.get(false)); } }
/** * @return {@code true} if this is a {@code some}, {@code false} otherwise. */ public final boolean isDefined() { return fold(Suppliers.ofInstance(false), forPredicate(Predicates.<A>alwaysTrue())); }
/** Apply post-processing to the entire list of results * See {@link CollectionFunctionals#all(Predicate)} and {@link CollectionFunctionals#quorum(org.apache.brooklyn.util.collections.QuorumCheck, Predicate) * which allow useful arguments. */ public MultiBuilder<T, V, Boolean> postProcessFromMultiple(final Predicate<? super List<V>> val) { return postProcessFromMultiple(Functions.forPredicate(val)); }
/** * @return {@code true} if this is a {@code some}, {@code false} otherwise. */ public final boolean isDefined() { return fold(Suppliers.ofInstance(false), forPredicate(Predicates.<A>alwaysTrue())); }
public final boolean isRight() { return fold(forPredicate(Predicates.<L>alwaysFalse()), forPredicate(Predicates.<R>alwaysTrue())); }
public final boolean isLeft() { return fold(forPredicate(Predicates.<L>alwaysTrue()), forPredicate(Predicates.<R>alwaysFalse())); }
public final boolean isRight() { return fold(forPredicate(Predicates.<L>alwaysFalse()), forPredicate(Predicates.<R>alwaysTrue())); }
public final boolean isLeft() { return fold(forPredicate(Predicates.<L>alwaysTrue()), forPredicate(Predicates.<R>alwaysFalse())); }
public static Function<HttpToolResponse, Boolean> responseCodeEquals(final int... expected) { List<Integer> expectedList = Lists.newArrayList(); for (int e : expected) { expectedList.add(e); } return Functionals.chain(HttpValueFunctions.responseCode(), Functions.forPredicate(Predicates.in(expectedList))); }
public static Function<HttpPollValue, Boolean> responseCodeEquals(final int... expected) { List<Integer> expectedList = Lists.newArrayList(); for (int e : expected) { expectedList.add((Integer)e); } return chain(HttpValueFunctions.responseCode(), Functions.forPredicate(Predicates.in(expectedList))); }
public static Function<HttpToolResponse, Boolean> responseCodeEquals(final int expected) { return Functionals.chain(HttpValueFunctions.responseCode(), Functions.forPredicate(Predicates.equalTo(expected))); }
public static Function<HttpPollValue, Boolean> responseCodeEquals(final int expected) { return chain(HttpValueFunctions.responseCode(), Functions.forPredicate(Predicates.equalTo(expected))); }
public static Function<SshPollValue, Boolean> exitStatusEquals(final int expected) { return chain(SshValueFunctions.exitStatus(), Functions.forPredicate(Predicates.equalTo(expected))); }
private boolean shouldIncludeItem(ActivityItem item) { Option<String> author = option(item.getChangedBy()); return any(getActivities(item), inActivities) && item.getSpaceKey().map(forPredicate(inProjectKeys)).getOrElse(!hasSpaceFilter) && anyUsers.apply(author) && notInUsers.apply(author) && followedUsers.apply(item.getChangedBy()) && inDateRange.apply(item.getModified()); }
@GwtIncompatible // SerializableTester public void testForPredicateSerializable() { checkCanReserialize(Functions.forPredicate(Predicates.equalTo(5))); }
public void testForPredicate() { Function<Object, Boolean> alwaysTrue = Functions.forPredicate(Predicates.alwaysTrue()); Function<Object, Boolean> alwaysFalse = Functions.forPredicate(Predicates.alwaysFalse()); assertTrue(alwaysTrue.apply(0)); assertFalse(alwaysFalse.apply(0)); new EqualsTester() .addEqualityGroup( alwaysTrue, Functions.forPredicate(Predicates.alwaysTrue())) .addEqualityGroup(alwaysFalse) .addEqualityGroup(Functions.identity()) .testEquals(); }
@Override protected void connectSensors() { setAttribute(BROKER_URL, String.format("tcp://%s:%d", getAttribute(HOSTNAME), getAttribute(OPEN_WIRE_PORT))); String brokerMbeanName = "org.apache.activemq:BrokerName=localhost,Type=Broker"; jmxFeed = JmxFeed.builder() .entity(this) .period(500, TimeUnit.MILLISECONDS) .pollAttribute(new JmxAttributePollConfig<Boolean>(SERVICE_UP) .objectName(brokerMbeanName) .attributeName("BrokerId") .onSuccess(Functions.forPredicate(Predicates.notNull())) .onFailureOrException(Functions.constant(false))) .build(); }
public static final EnricherSpec<?> newEnricherForServiceUpIfNotUpIndicatorsEmpty() { // The function means: if the serviceNotUpIndicators is not null, then serviceNotUpIndicators.size()==0; // otherwise return the default value. return Enrichers.builder() .transforming(SERVICE_NOT_UP_INDICATORS).<Object>publishing(Attributes.SERVICE_UP) .suppressDuplicates(true) .computing( Functionals.<Map<String,?>> ifNotEquals(null).<Object>apply(Functions.forPredicate(CollectionFunctionals.<String>mapSizeEquals(0))) .defaultValue(Entities.UNCHANGED) ) .uniqueTag(DEFAULT_ENRICHER_UNIQUE_TAG) .build(); }