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:net.automatalib.util.automata.predicates.TransitionPredicates.java

public static <S, I, T> TransitionPredicate<S, I, T> inputNotIn(Collection<?> inputs) {
    return inputSatisfying(Predicates.not(Predicates.in(inputs)));
}

From source file:com.google.errorprone.bugpatterns.inject.dagger.PrivateConstructorForNoninstantiableModule.java

@Override
public Description matchClass(ClassTree classTree, VisitorState state) {
    if (!DaggerAnnotations.isAnyModule().matches(classTree, state)) {
        return NO_MATCH;
    }//from w  ww  .  j a v a 2  s.  co  m

    // if a module is declared as an interface, skip it
    if (!classTree.getKind().equals(CLASS)) {
        return NO_MATCH;
    }

    FluentIterable<? extends Tree> nonSyntheticMembers = FluentIterable.from(classTree.getMembers())
            .filter(Predicates.not(new Predicate<Tree>() {
                @Override
                public boolean apply(Tree tree) {
                    return tree.getKind().equals(METHOD) && isGeneratedConstructor((MethodTree) tree);
                }
            }));

    // ignore empty modules
    if (nonSyntheticMembers.isEmpty()) {
        return NO_MATCH;
    }

    if (nonSyntheticMembers.anyMatch(IS_CONSTRUCTOR)) {
        return NO_MATCH;
    }

    boolean hasBindingDeclarationMethods = nonSyntheticMembers
            .anyMatch(matcherAsPredicate(isBindingDeclarationMethod(), state));

    if (hasBindingDeclarationMethods) {
        return describeMatch(classTree, addPrivateConstructor(classTree, state));
    }

    boolean allStaticMembers = nonSyntheticMembers.allMatch(matcherAsPredicate(isStatic(), state));

    if (allStaticMembers) {
        return describeMatch(classTree, addPrivateConstructor(classTree, state));
    }

    return NO_MATCH;
}

From source file:org.ow2.proactive.procci.Application.java

@Bean
public Docket procciApi() {
    return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).groupName("proactive").select()
            .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
            .paths(allowedPaths()).build();
}

From source file:google.registry.model.ofy.TransactionInfo.java

ImmutableSet<Object> getSaves() {
    return FluentIterable.from(changesBuilder.build().values()).filter(Predicates.not(IS_DELETE)).toSet();
}

From source file:org.apache.beam.runners.dataflow.worker.WindmillKeyedWorkItem.java

@Override
public Iterable<TimerData> timersIterable() {
    FluentIterable<Timer> allTimers = FluentIterable.from(workItem.getTimers().getTimersList());
    FluentIterable<Timer> eventTimers = allTimers.filter(IS_WATERMARK);
    FluentIterable<Timer> nonEventTimers = allTimers.filter(Predicates.not(IS_WATERMARK));
    return eventTimers.append(nonEventTimers).transform(timer -> WindmillTimerInternals
            .windmillTimerToTimerData(WindmillNamespacePrefix.SYSTEM_NAMESPACE_PREFIX, timer, windowCoder));
}

From source file:org.elasticsearch.index.codec.postingsformat.Elasticsearch090PostingsFormat.java

@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
    final BloomFilteredFieldsConsumer fieldsConsumer = bloomPostings.fieldsConsumer(state);
    return new FieldsConsumer() {

        @Override// www . jav a 2  s  .  c o m
        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.opentestsystem.shared.security.domain.SbacUser.java

public Collection<SbacRole> getNonEffectiveRoles() {
    Collection<SbacRole> roles = new ArrayList<>();
    for (Collection<SbacRole> sbacRoles : sbacRolesMap.values()) {
        Iterables.addAll(roles, Iterables.filter(sbacRoles,
                Predicates.not(RolesAndPermissionsServiceImpl.ROLE_APPLICABLE_TO_COMPONENT_FILTER)));
    }//from   w  w  w  .j av  a2  s.  co m
    return roles;
}

From source file:com.redpacket.server.SwaggerConfig.java

private List<SecurityContext> securityContexts() {
    List<SecurityContext> securityContexts = Arrays.asList(SecurityContext.builder()
            .forPaths(Predicates.not(PathSelectors.regex("^(/error.*|/api/auth/login)$")))
            .securityReferences(securityReferences()).build());
    return securityContexts;
}

From source file:org.apache.bazel.checkstyle.JavaCheckstyle.java

@SuppressWarnings("unchecked")
private static String[] getHeronSourceFiles(String extraActionFile) {
    return getSourceFiles(extraActionFile,
            Predicates.not(Predicates.or(Predicates.containsPattern("storm-compatibility-examples.src.java"),
                    Predicates.containsPattern("storm-compatibility.src.java"),
                    Predicates.containsPattern("tools/test/LcovMerger"), Predicates.containsPattern("contrib"),
                    Predicates.containsPattern("external") // from external/ directory for bazel
            )));/*w w w  . j a v  a2s .c o  m*/
}

From source file:brooklyn.event.basic.PortAttributeSensorAndConfigKey.java

@Override
protected Integer convertConfigToSensor(PortRange value, Entity entity) {
    if (value == null)
        return null;
    Collection<? extends Location> locations = entity.getLocations();
    if (!locations.isEmpty()) {
        Maybe<? extends Location> lo = Locations.findUniqueMachineLocation(locations);
        if (!lo.isPresent()) {
            // Try a unique location which isn't a machine provisioner
            Iterator<? extends Location> li = Iterables
                    .filter(locations, Predicates.not(Predicates.instanceOf(MachineProvisioningLocation.class)))
                    .iterator();/* w ww  . ja  va 2 s .c om*/
            if (li.hasNext())
                lo = Maybe.of(li.next());
            if (li.hasNext())
                lo = Maybe.absent();
        }
        // Fall back to selecting the single location
        if (!lo.isPresent() && locations.size() == 1) {
            lo = Maybe.of(locations.iterator().next());
        }
        if (LOG.isTraceEnabled()) {
            LOG.trace("Convert config to sensor for {} found locations: {}. Selected: {}",
                    new Object[] { entity, locations, lo });
        }
        if (lo.isPresent()) {
            Location l = lo.get();
            Optional<Boolean> locationRunning = Optional
                    .fromNullable(l.getConfig(BrooklynConfigKeys.SKIP_ENTITY_START_IF_RUNNING));
            Optional<Boolean> entityRunning = Optional
                    .fromNullable(entity.getConfig(BrooklynConfigKeys.SKIP_ENTITY_START_IF_RUNNING));
            Optional<Boolean> locationInstalled = Optional
                    .fromNullable(l.getConfig(BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION));
            Optional<Boolean> entityInstalled = Optional
                    .fromNullable(entity.getConfig(BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION));
            Optional<Boolean> entityStarted = Optional
                    .fromNullable(entity.getConfig(BrooklynConfigKeys.SKIP_ENTITY_START));
            boolean skipCheck = locationRunning.or(entityRunning).or(locationInstalled).or(entityInstalled)
                    .or(entityStarted).or(false);
            if (l instanceof PortSupplier) {
                int p = ((PortSupplier) l).obtainPort(value);
                if (p != -1) {
                    LOG.debug("{}: choosing port {} for {}", new Object[] { entity, p, getName() });
                    return p;
                }
                // If we are not skipping install or already started, fail now
                if (!skipCheck) {
                    int rangeSize = Iterables.size(value);
                    if (rangeSize == 0) {
                        LOG.warn("{}: no port available for {} (empty range {})",
                                new Object[] { entity, getName(), value });
                    } else if (rangeSize == 1) {
                        Integer pp = value.iterator().next();
                        if (pp > 1024) {
                            LOG.warn("{}: port {} not available for {}",
                                    new Object[] { entity, pp, getName() });
                        } else {
                            LOG.warn("{}: port {} not available for {} (root may be required?)",
                                    new Object[] { entity, pp, getName() });
                        }
                    } else {
                        LOG.warn("{}: no port available for {} (tried range {})",
                                new Object[] { entity, getName(), value });
                    }
                    return null; // Definitively, no ports available
                }
            }
            // Ports may be available, we just can't tell from the location
            Integer v = (value.isEmpty() ? null : value.iterator().next());
            LOG.debug("{}: choosing port {} (unconfirmed) for {}", new Object[] { entity, v, getName() });
            return v;
        } else {
            LOG.warn(
                    "{}: ports not applicable, or not yet applicable, because has multiple locations {}; ignoring ",
                    new Object[] { entity, locations, getName() });
        }
    } else {
        LOG.warn("{}: ports not applicable, or not yet applicable, bacause has no locations; ignoring {}",
                entity, getName());
    }
    return null;
}