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:com.ansorgit.plugins.bash.editor.codecompletion.CompletionProviderUtils.java

static Collection<LookupElement> createPathItems(List<String> paths) {
    Function<String, LookupElement> transformationFunction = new Function<String, LookupElement>() {
        public LookupElement apply(String path) {
            return new PathLookupElement(path, !path.endsWith("/"));
        }/*from   w  w w . j a v a2s .c  o m*/
    };

    Predicate<String> isRelativePath = new Predicate<String>() {
        public boolean apply(String path) {
            return !path.startsWith("/");
        }
    };

    Collection<String> relativePaths = Collections2.filter(paths, isRelativePath);
    Collection<LookupElement> relativePathItems = Collections2.transform(relativePaths, transformationFunction);

    Collection<String> absolutePaths = Collections2.filter(paths, Predicates.not(isRelativePath));
    Collection<LookupElement> absolutePathItems = Collections2.transform(absolutePaths, transformationFunction);

    Collection<LookupElement> result = Lists.newLinkedList();
    result.addAll(wrapInGroup(CompletionGrouping.RelativeFilePath.ordinal(), relativePathItems));
    result.addAll(wrapInGroup(CompletionGrouping.AbsoluteFilePath.ordinal(), absolutePathItems));

    return result;
}

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//w  w w.ja v  a2 s .co  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.");
}

From source file:playground.michalm.poznan.demand.taxi.PoznanServedRequests.java

public static Iterable<ServedRequest> filterNormalPeriods(Iterable<ServedRequest> requests) {
    //February - 1-28 (4 full weeks)
    //March - 2-29 (4 full weeks) - exclude: 1, 30-31 (daylight saving time shift)
    //April - 1-14 + 23-29 (3 full weeks), exclude: 15-22, 30 (Easter and May's long weekend)

    @SuppressWarnings("unchecked")
    //TODO WEIRD JAVAC COMPILER PROBLEM:
    //necessary casting from Predicate<ServedRequest> to Predicate<? super ServedRequest>
    Predicate<? super ServedRequest> orPredicate = Predicates.or(
            (Predicate<? super ServedRequest>) ServedRequests.createBetweenDatesPredicate(midnight("01-03"),
                    midnight("02-03")),
            (Predicate<? super ServedRequest>) ServedRequests.createBetweenDatesPredicate(midnight("30-03"),
                    midnight("01-04")),
            (Predicate<? super ServedRequest>) ServedRequests.createBetweenDatesPredicate(midnight("15-04"),
                    midnight("23-04")),
            (Predicate<? super ServedRequest>) ServedRequests.createBetweenDatesPredicate(midnight("30-04"),
                    midnight("01-05")));

    return Iterables.filter(requests, Predicates.not(orPredicate));
}

From source file:com.micro.security.SecurityTokenApp.java

/**
 * Swagger 2 docket bean configuration.// w w w.j av a2  s  .com
 *
 * @return swagger 2 Docket.
 */
@Bean
public Docket resolverApi() throws Exception {
    return new Docket(DocumentationType.SWAGGER_2).groupName("security-app").apiInfo(apiInfo()).select()
            .paths(Predicates.not(PathSelectors.regex("/error"))) // Exclude Spring error controllers
            .build();
}

From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.CreateMessageCreationValidator.java

/**
 * Check that there is not {@link ISequenceEvent} on the target lifeline
 * with range's lowerbound lower than the firstClickLocation.y .
 * //from  ww w.j a va2  s.c o m
 * @return true if not {@link ISequenceEvent} lower than
 *         firstClickLocation.y
 */
private boolean checkNotEventAtLowerTimeInSameLifeline() {
    boolean valid = true;

    SequenceDiagram sequenceDiagram = sequenceElementSource.getDiagram();
    SequenceDiagramQuery sequenceDiagramQuery = new SequenceDiagramQuery(sequenceDiagram);
    for (ISequenceEvent sequenceEvent : Iterables.filter(
            sequenceDiagramQuery.getAllSequenceEventsLowerThan(firstClickLocation.y),
            Predicates.not(Predicates.instanceOf(Lifeline.class)))) {
        if (isSequenceEventOfLifeline(sequenceEvent, sequenceElementTarget.getLifeline())
                || isMessageTargeting(sequenceEvent, sequenceElementTarget.getLifeline()) || isCreateMessageFor(
                        sequenceEvent, sequenceElementTarget.getLifeline().get().getInstanceRole())) {
            valid = false;
            break;
        }
    }
    return valid;
}

From source file:org.opentestsystem.shared.progman.transformer.TenantComponentTransformer.java

@Override
public Tenant apply(final Tenant tenant) {
    if (tenant != null && tenant.getTenantSubscriptions() != null) {
        final Iterable<TenantSubscription> matchingTenantSubscriptionList = Iterables.transform(
                Iterables.filter(tenant.getTenantSubscriptions(), this.matchingTenantSub),
                this.tenantSubscriptionTransformer);
        final List<TenantSubscription> tenantSubsToPreserve = Lists.newArrayList(
                Iterables.filter(tenant.getTenantSubscriptions(), Predicates.not(this.matchingTenantSub)));
        if (this.retain) {
            Iterables.addAll(tenantSubsToPreserve, matchingTenantSubscriptionList);
        }//from   w w w  .j  a  v  a2  s .  co m
        tenant.setTenantSubscriptions(tenantSubsToPreserve);
    }
    return tenant;
}

From source file:net.automatalib.util.automata.predicates.TransitionPredicates.java

public static <S, I, T> TransitionPredicate<S, I, T> inputIsNot(Object input) {
    return inputSatisfying(Predicates.not(Predicates.equalTo(input)));
}

From source file:org.elasticsearch.index.codec.postingformat.Elasticsearch090RWPostingsFormat.java

@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
    final PostingsFormat delegate = getDefaultWrapped();
    final BloomFilteredFieldsConsumer fieldsConsumer = new BloomFilterPostingsFormat(delegate,
            BloomFilter.Factory.DEFAULT) {
        @Override/*from w w  w  . j a va  2s.co  m*/
        public BloomFilteredFieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
            return new BloomFilteredFieldsConsumer(delegate.fieldsConsumer(state), state, delegate);
        }
    }.fieldsConsumer(state);
    return new FieldsConsumer() {

        @Override
        public void write(Fields fields) throws IOException {

            Fields maskedFields = new FilterLeafReader.FilterFields(fields) {
                @Override
                public Iterator<String> iterator() {
                    return Iterators.filter(this.in.iterator(), Predicates.not(UID_FIELD_FILTER));
                }
            };
            fieldsConsumer.getDelegate().write(maskedFields);
            maskedFields = new FilterLeafReader.FilterFields(fields) {
                @Override
                public Iterator<String> iterator() {
                    return Iterators.singletonIterator(UidFieldMapper.NAME);
                }
            };
            // only go through bloom for the UID field
            fieldsConsumer.write(maskedFields);
        }

        @Override
        public void close() throws IOException {
            fieldsConsumer.close();
        }
    };
}

From source file:org.sonar.server.computation.step.FeedDebtModelStep.java

private void feedDebtModel(DbSession session) {
    List<CharacteristicDto> characteristicDtos = dbClient.debtCharacteristicDao()
            .selectEnabledCharacteristics(session);
    Map<Integer, CharacteristicDto> rootCharacteristicsById = FluentIterable.from(characteristicDtos)
            .filter(IsRootPredicate.INSTANCE).uniqueIndex(CharacteristicDtoToId.INSTANCE);

    for (Map.Entry<Integer, Collection<CharacteristicDto>> entry : FluentIterable.from(characteristicDtos)
            .filter(Predicates.not(IsRootPredicate.INSTANCE)).index(CharacteristicDtoToParentId.INSTANCE)
            .asMap().entrySet()) {//from   w ww .  j  av  a2 s  .c o m
        mutableDebtModelHolder.addCharacteristics(toCharacteristic(rootCharacteristicsById.get(entry.getKey())),
                FluentIterable.from(entry.getValue()).transform(CharacteristicDtoToCharacteristic.INSTANCE));
    }
}

From source file:ezbake.data.graph.blueprints.visibility.VisibilityFilterQuery.java

@Override
public Query hasNot(final String key) {
    predicates.add(Predicates.not(hasKeyPredicate(key)));

    return this;
}