Java Code Examples for org.eclipse.collections.impl.block.factory.Predicates#alwaysTrue()

The following examples show how to use org.eclipse.collections.impl.block.factory.Predicates#alwaysTrue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LookupPredicateBuilder.java    From obevo with Apache License 2.0 6 votes vote down vote up
public static Predicates<? super String> convert(ImmutableCollection<String> patterns) {
    if (patterns == null) {
        return Predicates.alwaysTrue();
    }
    PartitionIterable<String> wildcardPartition = patterns.partition(Predicates.or(StringPredicates.contains("*"), StringPredicates.contains("%")));
    RichIterable<String> wildcardPatterns = wildcardPartition.getSelected();
    RichIterable<WildcardPatternIndex> wildcardPatternIndexes = wildcardPatterns.collect(new Function<String, WildcardPatternIndex>() {
        @Override
        public WildcardPatternIndex valueOf(String patternString) {
            return new WildcardPatternIndex(patternString);
        }
    });

    RichIterable<String> lookupPatterns = wildcardPartition.getRejected();
    LookupIndex lookupIndex = lookupPatterns.notEmpty() ? new LookupIndex(lookupPatterns.toSet().toImmutable()) : null;

    MutableList<Index> indexes = Lists.mutable.empty();
    if (lookupIndex != null) {
        indexes.add(lookupIndex);
    }
    indexes.withAll(wildcardPatternIndexes);

    return Predicates.or(indexes);
}
 
Example 2
Source File: ObjectTypeAndNamePredicateBuilder.java    From obevo with Apache License 2.0 5 votes vote down vote up
/**
 * Builds the predicate on object type and name based on the input functions passed in.
 */
public <T> Predicates<? super T> build(final Function<? super T, String> objectTypeFunction, final Function<? super T, String> objectNameFunction) {
    if (objectNamesByType.isEmpty()) {
        if (filterType == null || filterType.isEmptyInputResult()) {
            return Predicates.alwaysTrue();
        } else {
            return Predicates.alwaysFalse();
        }
    }

    RichIterable<Predicate<? super T>> typePredicates = objectNamesByType.keyMultiValuePairsView().toList().collect(new Function<Pair<String, RichIterable<String>>, Predicate<? super T>>() {
        @Override
        public Predicate<? super T> valueOf(Pair<String, RichIterable<String>> pair) {
            String objectType = pair.getOne();
            RichIterable<String> objectPatterns = pair.getTwo();
            boolean negatePredicate = filterType == FilterType.EXCLUDE;
            if (objectType.startsWith("-")) {
                objectType = objectType.substring(1);
                negatePredicate = true;
            }

            Predicate<T> objectTypeAndNamePredicate = getObjectTypeAndNamePredicate(
                    objectTypeFunction, Lists.immutable.with(objectType),
                    negatePredicate, objectNameFunction, objectPatterns.toList().toImmutable()
            );

            return objectTypeAndNamePredicate;
        }
    });

    if (filterType == null || filterType == FilterType.EXCLUDE) {
        return Predicates.and(typePredicates);
    } else {
        return Predicates.or(typePredicates);
    }
}
 
Example 3
Source File: LookupPredicateBuilder.java    From obevo with Apache License 2.0 5 votes vote down vote up
public static <T> Predicates<? super T> convert(Function<? super T, String> typeFunction, ImmutableCollection<String> patterns) {
    if (patterns.isEmpty()) {
        return Predicates.alwaysTrue();
    } else {
        return Predicates.attributePredicate(typeFunction, convert(patterns));
    }
}
 
Example 4
Source File: AbstractDeployerAppContext.java    From obevo with Apache License 2.0 4 votes vote down vote up
protected Predicate<? super ChangeKey> getDbChangeFilter() {
    return Predicates.alwaysTrue();
}