Example usage for com.google.common.base Predicates not

List of usage examples for com.google.common.base Predicates not

Introduction

In this page you can find the example usage for com.google.common.base Predicates not.

Prototype

public static <T> Predicate<T> not(Predicate<T> predicate) 

Source Link

Document

Returns a predicate that evaluates to true if the given predicate evaluates to false .

Usage

From source file:org.trancecode.lang.StringPredicates.java

public static Predicate<String> isNotEmpty() {
    // TODO singleton
    return Predicates.not(isEmpty());
}

From source file:com.madvay.tools.android.perf.common.TraceTransformers.java

public static TT prune(final Predicate<StackTraceElement> spec) {
    return new TT() {
        @Override/*from w w  w. j av  a 2s  .  c om*/
        public List<StackTraceElement> apply(List<StackTraceElement> input) {
            return Lists.newArrayList(Collections2.filter(input, Predicates.not(spec)));
        }
    };
}

From source file:org.batoo.jpa.parser.MappingException.java

private static String getLocation(AbstractLocator[] locators) {
    if (locators == null) {
        return "";
    }/*from   w w w .  j av  a2  s . c om*/

    final Collection<AbstractLocator> filteredLocators = Collections2.filter(Arrays.asList(locators),
            Predicates.not(Predicates.isNull()));
    if (filteredLocators.size() == 0) {
        return "";
    }

    return " Defined at:" + (filteredLocators.size() > 1 ? "\n\t" : " ")
            + Joiner.on("\n\t").skipNulls().join(filteredLocators);
}

From source file:com.facebook.buck.rules.DependencyAggregationTestUtil.java

/**
 * Return dependencies of a rule, traversing through any dependency aggregations.
 *///w w  w .  ja  v a 2  s  .co m
public static Iterable<BuildRule> getDisaggregatedDeps(BuildRule rule) {
    return FluentIterable.from(rule.getDeps()).filter(DependencyAggregation.class)
            .transformAndConcat(new Function<DependencyAggregation, Iterable<BuildRule>>() {
                @Override
                public Iterable<BuildRule> apply(DependencyAggregation input) {
                    return input.getDeps();
                }
            }).append(Iterables.filter(rule.getDeps(),
                    Predicates.not(Predicates.instanceOf(DependencyAggregation.class))));
}

From source file:de.flapdoodle.guava.Merger.java

public static <T> ImmutableList<T> merge(Iterable<? extends T> left, Iterable<? extends T> right,
        Equivalence<? super T> matcher, Foldleft<? super T, T> fold) {
    ImmutableList.Builder<T> builder = ImmutableList.builder();
    Iterable<? extends T> notMerged = right;
    for (T l : left) {
        Iterable<? extends T> matching = Iterables.filter(notMerged, matcher.equivalentTo(l));
        notMerged = Iterables.filter(notMerged, Predicates.not(matcher.equivalentTo(l)));

        boolean noMatching = true;
        for (T r : matching) {
            builder.add(fold.apply(l, r));
            noMatching = false;//from w ww .j  a  v  a2 s.  c  o  m
        }
        if (noMatching) {
            builder.add(l);
        }
    }
    builder.addAll(notMerged);
    return builder.build();
}

From source file:uk.co.blackpepper.common.model.Identifiables.java

public static <T extends Identifiable<?>> Iterable<T> getTransients(Iterable<T> identifiables) {
    return Iterables.filter(identifiables, Predicates.not(arePersistent()));
}

From source file:minium.actions.internal.WaitMocks.java

public static void mock() {
    Waits.setInstance(new Wait() {
        @Override/*from   w ww  .j a v a2  s. c  o  m*/
        public void time(Duration waitTime) {
            // don't wait
        }

        @Override
        @SuppressWarnings("unchecked")
        protected <T> Retryer<T> getRetryer(Predicate<? super T> predicate, Duration timeout,
                Duration interval) {
            int numRetries = (int) (timeout.getTime() / interval.getTime());
            // we emulate the number of retries
            return RetryerBuilder.<T>newBuilder().retryIfResult(Predicates.not((Predicate<T>) predicate))
                    .retryIfRuntimeException().withWaitStrategy(WaitStrategies.noWait())
                    .withStopStrategy(StopStrategies.stopAfterAttempt(numRetries)).build();
        }
    });
}

From source file:io.usethesource.criterion.FootprintUtils.java

public static String measureAndReport(final Object objectToMeasure, final String className, DataType dataType,
        Archetype archetype, boolean supportsStagedMutability, int size, int run,
        MemoryFootprintPreset preset) {/*from   www. j av  a  2 s.c  om*/
    final Predicate<Object> predicate;

    switch (preset) {
    case DATA_STRUCTURE_OVERHEAD:
        predicate = Predicates.not(Predicates.instanceOf(JmhValue.class));
        break;
    case RETAINED_SIZE:
        predicate = Predicates.alwaysTrue();
        break;
    default:
        throw new IllegalStateException();
    }

    // System.out.println(GraphLayout.parseInstance(objectToMeasure).totalSize());

    long memoryInBytes = objectexplorer.MemoryMeasurer.measureBytes(objectToMeasure, predicate);

    Footprint memoryFootprint = objectexplorer.ObjectGraphMeasurer.measure(objectToMeasure, predicate);

    final String statString = String.format("%d\t %60s\t[%s]\t %s", memoryInBytes, className, dataType,
            memoryFootprint);
    System.out.println(statString);

    final String statFileString = String.format("%d,%d,%s,%s,%s,%b,%d,%d,%d", size, run, className, dataType,
            archetype, supportsStagedMutability, memoryInBytes, memoryFootprint.getObjects(),
            memoryFootprint.getReferences());

    return statFileString;
}

From source file:iterator.util.Utils.java

public static <T> T waitFor(final Predicate<T> predicate, final Supplier<T> input) {
    for (int spin = 0; Predicates.not(predicate).apply(input.get());) {
        if (++spin % 10_000_000 == 0)
            System.err.print('.');
    }/*  w  w w  .ja  va 2s .  c  o  m*/
    T result = input.get();
    System.err.println(result.getClass().getName());
    return result;
}

From source file:org.trancecode.collection.TcMaps.java

public static <K, V> Map<K, V> merge(final Map<K, V> map1, final Map<? extends K, ? extends V> map2) {
    final Builder<K, V> builder = ImmutableMap.builder();
    @SuppressWarnings("unchecked")
    final Set<K> map2keys = (Set<K>) map2.keySet();
    final Predicate<K> keyFilter = Predicates.not(TcPredicates.isContainedBy(map2keys));
    final Map<K, V> map1WithoutKeysFromMap2 = Maps.filterKeys(map1, keyFilter);
    return builder.putAll(map1WithoutKeysFromMap2).putAll(map2).build();
}