PredicateUtils.equalPredicate(childValue)); if (lineageIndex == -1) { out.print(childValue);
/** * Creates a Predicate that invokes a method on the input object. * The method must return either a boolean or a non-null Boolean, * and have no parameters. If the input object is null, a * PredicateException is thrown. * <p> * For example, <code>PredicateUtils.invokerPredicate("isEmpty");</code> * will call the <code>isEmpty</code> method on the input object to * determine the predicate result. * * @param <T> the type that the predicate queries * @param methodName the method name to call on the input object, may not be null * @return the predicate * @throws NullPointerException if the methodName is null. * @see InvokerTransformer * @see TransformerPredicate */ public static <T> Predicate<T> invokerPredicate(final String methodName) { // reuse transformer as it has caching - this is lazy really, should have inner class here return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName)); }
/** * Create a new Predicate that returns true if neither of the specified * predicates are true. * * @param <T> the type that the predicate queries * @param predicate1 the first predicate, may not be null * @param predicate2 the second predicate, may not be null * @return the <code>neither</code> predicate * @throws NullPointerException if either predicate is null * @see NonePredicate */ public static <T> Predicate<T> neitherPredicate(final Predicate<? super T> predicate1, final Predicate<? super T> predicate2) { @SuppressWarnings("unchecked") final Predicate<T> nonePredicate = PredicateUtils.nonePredicate(predicate1, predicate2); return nonePredicate; }
@NonNull public static <T extends Enum, U> Predicate<U> predicate(@NonNull Class<T> enumType, @NonNull Collection<T> input, @NonNull Transformer<T, Predicate<U>> transformer) { if (input.size() >= values(enumType).size()) { return PredicateUtils.truePredicate(); } return PredicateUtils.anyPredicate(CollectionUtils.collect(input, transformer)); }
/** * Lists the history records that match this filter and that are older than the specified offset record. * * @param offsetRecordId specifies the offset record (where to start from); pass {@code null} to start from the * most recent record in the history * @param limit the maximum number of records to return from the specified offset * @return a list of history records that match this filter and are older than the specified offset record */ public List<ExtensionJobHistoryRecord> list(String offsetRecordId, int limit) { return history.getRecords(PredicateUtils.allPredicate(this.constraints), offsetRecordId, limit); } }
@Override public boolean evaluate(Predicate<WiFiDetail> object) { return !PredicateUtils.truePredicate().equals(object); } }
/** * Create a new Predicate that returns true if one, but not both, of the * specified predicates are true. XOR * * @param <T> the type that the predicate queries * @param predicate1 the first predicate, may not be null * @param predicate2 the second predicate, may not be null * @return the <code>either</code> predicate * @throws NullPointerException if either predicate is null * @see OnePredicate */ public static <T> Predicate<T> eitherPredicate(final Predicate<? super T> predicate1, final Predicate<? super T> predicate2) { @SuppressWarnings("unchecked") final Predicate<T> onePredicate = PredicateUtils.onePredicate(predicate1, predicate2); return onePredicate; }
/** * Filter the collection by applying a Predicate to each element. If the * predicate returns true, remove the element. * <p> * This is equivalent to <pre>filter(collection, PredicateUtils.notPredicate(predicate))</pre> * if predicate is != null. * <p> * If the input collection or predicate is null, there is no change made. * * @param <T> the type of object the {@link Iterable} contains * @param collection the collection to get the input from, may be null * @param predicate the predicate to use as a filter, may be null * @return true if the collection is modified by this call, false otherwise. */ public static <T> boolean filterInverse(final Iterable<T> collection, final Predicate<? super T> predicate) { return filter(collection, predicate == null ? null : PredicateUtils.notPredicate(predicate)); }
@NonNull @Override public List<String> findVendors(@NonNull String filter) { Predicate<String> predicate = PredicateUtils.anyPredicate(new StringContains(filter), new MacContains(filter)); return new ArrayList<>(CollectionUtils.select(getVendors().keySet(), predicate)); }
@Test public void testFindUsingPredicateWhenNothingFound() { // setup TestObject expected = TestObject.VALUE2; Predicate<TestObject> predicate = PredicateUtils.falsePredicate(); // execute TestObject actual = EnumUtils.find(TestObject.class, predicate, expected); // validate assertEquals(expected, actual); }
@NonNull private Predicate<WiFiDetail> makeSSIDPredicate(Set<String> ssids) { if (ssids.isEmpty()) { return PredicateUtils.truePredicate(); } return PredicateUtils.anyPredicate(CollectionUtils.collect(ssids, new SSIDTransformer())); }
private FilterPredicate(@NonNull Settings settings, @NonNull Set<WiFiBand> wiFiBands) { Predicate<WiFiDetail> ssidPredicate = makeSSIDPredicate(settings.getSSIDs()); Predicate<WiFiDetail> wiFiBandPredicate = EnumUtils.predicate(WiFiBand.class, wiFiBands, new WiFiBandTransformer()); Predicate<WiFiDetail> strengthPredicate = EnumUtils.predicate(Strength.class, settings.getStrengths(), new StrengthTransformer()); Predicate<WiFiDetail> securityPredicate = EnumUtils.predicate(Security.class, settings.getSecurities(), new SecurityTransformer()); List<Predicate<WiFiDetail>> predicates = Arrays.asList(ssidPredicate, wiFiBandPredicate, strengthPredicate, securityPredicate); this.predicate = PredicateUtils.allPredicate(CollectionUtils.select(predicates, new NoTruePredicate())); }
@Override public Predicate<TestObject> transform(TestObject input) { return PredicateUtils.truePredicate(); } }
/** * @see org.opencastproject.serviceregistry.impl.jmx.ServicesStatisticsMXBean#getWarningServiceCount() */ @Override public int getWarningServiceCount() { return CollectionUtils.countMatches(services.values(), PredicateUtils.equalPredicate(ServiceState.WARNING)); }
/** * Creates a Predicate that invokes a method on the input object. * The method must return either a boolean or a non-null Boolean, * and have no parameters. If the input object is null, a * PredicateException is thrown. * <p> * For example, <code>PredicateUtils.invokerPredicate("isEmpty");</code> * will call the <code>isEmpty</code> method on the input object to * determine the predicate result. * * @param <T> the type that the predicate queries * @param methodName the method name to call on the input object, may not be null * @param paramTypes the parameter types * @param args the arguments * @return the predicate * @throws NullPointerException if the method name is null * @throws IllegalArgumentException if the paramTypes and args don't match * @see InvokerTransformer * @see TransformerPredicate */ public static <T> Predicate<T> invokerPredicate(final String methodName, final Class<?>[] paramTypes, final Object[] args) { // reuse transformer as it has caching - this is lazy really, should have inner class here return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName, paramTypes, args)); }
/** * @see org.opencastproject.serviceregistry.impl.jmx.HostsStatisticsMXBean#getOfflineCount() */ @Override public int getOfflineCount() { return CollectionUtils.countMatches(hosts.values(), PredicateUtils.equalPredicate(OFFLINE)); }
/** * @see org.opencastproject.serviceregistry.impl.jmx.ServicesStatisticsMXBean#getNormalServiceCount() */ @Override public int getNormalServiceCount() { return CollectionUtils.countMatches(services.values(), PredicateUtils.equalPredicate(ServiceState.NORMAL)); }
/** * @see org.opencastproject.serviceregistry.impl.jmx.HostsStatisticsMXBean#getInMaintenanceCount() */ @Override public int getInMaintenanceCount() { return CollectionUtils.countMatches(hosts.values(), PredicateUtils.equalPredicate(MAINTENANCE)); }
/** * @see org.opencastproject.serviceregistry.impl.jmx.ServicesStatisticsMXBean#getErrorServiceCount() */ @Override public int getErrorServiceCount() { return CollectionUtils.countMatches(services.values(), PredicateUtils.equalPredicate(ServiceState.ERROR)); }
/** * @see org.opencastproject.serviceregistry.impl.jmx.HostsStatisticsMXBean#getOnlineCount() */ @Override public int getOnlineCount() { return CollectionUtils.countMatches(hosts.values(), PredicateUtils.equalPredicate(ONLINE)); }