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.google.devtools.build.lib.query2.SkyQueryEnvironment.java

@Override
public void buildTransitiveClosure(QueryExpression caller, Set<Target> targets, int maxDepth)
        throws QueryException, InterruptedException {
    // Everything has already been loaded, so here we just check for errors so that we can
    // pre-emptively throw/report if needed.
    Iterable<SkyKey> transitiveTraversalKeys = makeTransitiveTraversalKeys(targets);
    ImmutableList.Builder<String> errorMessagesBuilder = ImmutableList.builder();

    // First, look for errors in the successfully evaluated TransitiveTraversalValues. They may
    // have encountered errors that they were able to recover from.
    Set<Entry<SkyKey, SkyValue>> successfulEntries = graph.getSuccessfulValues(transitiveTraversalKeys)
            .entrySet();//  w  ww  .jav a 2  s  . co m
    Builder<SkyKey> successfulKeysBuilder = ImmutableSet.builder();
    for (Entry<SkyKey, SkyValue> successfulEntry : successfulEntries) {
        successfulKeysBuilder.add(successfulEntry.getKey());
        TransitiveTraversalValue value = (TransitiveTraversalValue) successfulEntry.getValue();
        String firstErrorMessage = value.getFirstErrorMessage();
        if (firstErrorMessage != null) {
            errorMessagesBuilder.add(firstErrorMessage);
        }
    }
    ImmutableSet<SkyKey> successfulKeys = successfulKeysBuilder.build();

    // Next, look for errors from the unsuccessfully evaluated TransitiveTraversal skyfunctions.
    Iterable<SkyKey> unsuccessfulKeys = Iterables.filter(transitiveTraversalKeys,
            Predicates.not(Predicates.in(successfulKeys)));
    Set<Entry<SkyKey, Exception>> errorEntries = graph.getMissingAndExceptions(unsuccessfulKeys).entrySet();
    for (Map.Entry<SkyKey, Exception> entry : errorEntries) {
        if (entry.getValue() == null) {
            // Targets may be in the graph because they are not in the universe or depend on cycles.
            eventHandler.handle(Event.warn(entry.getKey().argument() + " does not exist in graph"));
        } else {
            errorMessagesBuilder.add(entry.getValue().getMessage());
        }
    }

    // Lastly, report all found errors.
    ImmutableList<String> errorMessages = errorMessagesBuilder.build();
    for (String errorMessage : errorMessages) {
        reportBuildFileError(caller, errorMessage);
    }
}

From source file:hudson.Functions.java

/**
 * @deprecated This is rather meaningless.
 *//*from   w  w  w. ja va2s . com*/
@Deprecated
public static Collection<Descriptor> getSortedDescriptorsForGlobalConfigNoSecurity() {
    return getSortedDescriptorsForGlobalConfig(Predicates.not(GlobalSecurityConfiguration.FILTER));
}

From source file:com.facebook.buck.config.BuckConfig.java

public ImmutableMap<String, ImmutableMap<String, String>> getRawConfigForParser() {
    ImmutableMap<String, ImmutableMap<String, String>> rawSections = config.getSectionToEntries();

    // If the raw config doesn't have sections which have ignored fields, then just return it as-is.
    ImmutableSet<String> sectionsWithIgnoredFields = IGNORE_FIELDS_FOR_DAEMON_RESTART.keySet();
    if (Sets.intersection(rawSections.keySet(), sectionsWithIgnoredFields).isEmpty()) {
        return rawSections;
    }//w w  w. jav a  2s . c  o  m

    // Otherwise, iterate through the config to do finer-grain filtering.
    ImmutableMap.Builder<String, ImmutableMap<String, String>> filtered = ImmutableMap.builder();
    for (Map.Entry<String, ImmutableMap<String, String>> sectionEnt : rawSections.entrySet()) {
        String sectionName = sectionEnt.getKey();

        // If this section doesn't have a corresponding ignored section, then just add it as-is.
        if (!sectionsWithIgnoredFields.contains(sectionName)) {
            filtered.put(sectionEnt);
            continue;
        }

        // If none of this section's entries are ignored, then add it as-is.
        ImmutableMap<String, String> fields = sectionEnt.getValue();
        ImmutableSet<String> ignoredFieldNames = IGNORE_FIELDS_FOR_DAEMON_RESTART.getOrDefault(sectionName,
                ImmutableSet.of());
        if (Sets.intersection(fields.keySet(), ignoredFieldNames).isEmpty()) {
            filtered.put(sectionEnt);
            continue;
        }

        // Otherwise, filter out the ignored fields.
        ImmutableMap<String, String> remainingKeys = ImmutableMap
                .copyOf(Maps.filterKeys(fields, Predicates.not(ignoredFieldNames::contains)));

        if (!remainingKeys.isEmpty()) {
            filtered.put(sectionName, remainingKeys);
        }
    }

    return filtered.build();
}

From source file:org.carrot2.workbench.core.ui.SearchEditor.java

/**
 * Get hold of the algorithm instance, extract its attribute descriptors.
 *//*from   w  ww  .  j  av a2 s  . c  o  m*/
@SuppressWarnings("unchecked")
BindableDescriptor getAlgorithmDescriptor() {
    final WorkbenchCorePlugin core = WorkbenchCorePlugin.getDefault();
    final String algorithmID = getSearchResult().getInput().getAlgorithmId();

    BindableDescriptor componentDescriptor = core.getComponentDescriptor(algorithmID);
    if (componentDescriptor == null) {
        throw new RuntimeException("No descriptor for algorithm: " + algorithmID);
    }
    return componentDescriptor.only(Input.class, Processing.class)
            .only(Predicates.not(new InternalAttributePredicate(false)));
}

From source file:org.apache.cassandra.thrift.CassandraServer.java

private void validateSchemaAgreement() throws SchemaDisagreementException {
    // unreachable hosts don't count towards disagreement
    Map<String, List<String>> versions = Maps.filterKeys(StorageProxy.describeSchemaVersions(),
            Predicates.not(Predicates.equalTo(StorageProxy.UNREACHABLE)));
    if (versions.size() > 1)
        throw new SchemaDisagreementException();
}

From source file:dagger2.internal.codegen.BindingGraphValidator.java

private void reportCycle(DependencyRequest request, Deque<ResolvedRequest> path,
        final ValidationReport.Builder<BindingGraph> reportBuilder) {
    ImmutableList<DependencyRequest> pathElements = ImmutableList.<DependencyRequest>builder().add(request)
            .addAll(Iterables.transform(path, REQUEST_FROM_RESOLVED_REQUEST)).build();
    ImmutableList<String> printableDependencyPath = FluentIterable.from(pathElements)
            .transform(dependencyRequestFormatter).filter(Predicates.not(Predicates.equalTo(""))).toList()
            .reverse();//  w  ww.j ava  2  s  .  c o m
    DependencyRequest rootRequest = path.getLast().request();
    TypeElement componentType = MoreElements.asType(rootRequest.requestElement().getEnclosingElement());
    // TODO(cgruber): Restructure to provide a hint for the start and end of the cycle.
    reportBuilder
            .addItem(
                    String.format(ErrorMessages.CONTAINS_DEPENDENCY_CYCLE_FORMAT,
                            componentType.getQualifiedName(), rootRequest.requestElement().getSimpleName(),
                            Joiner.on("\n")
                                    .join(printableDependencyPath.subList(1, printableDependencyPath.size()))),
                    rootRequest.requestElement());
}

From source file:org.eclipse.sirius.diagram.ui.tools.api.figure.locator.DBorderItemLocator.java

/**
 * Get the figures of the brother's border nodes of
 * <code>targetBorderItem</code>.
 * //from  w  w  w .  java 2 s . co m
 * @param targetBorderItem
 *            Contextual border item.
 * @return The list of figure of the brother border nodes.
 */
protected List<IFigure> getBrotherFigures(final IFigure targetBorderItem) {
    @SuppressWarnings("unchecked")
    Iterable<IFigure> brotherFigures = Iterables.filter(targetBorderItem.getParent().getChildren(), Predicates
            .and(Predicates.instanceOf(IFigure.class), Predicates.not(Predicates.equalTo(targetBorderItem))));
    return Lists.newArrayList(brotherFigures);
}

From source file:processing.app.Base.java

public LibraryList getIDELibs() {
    LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries());
    List<UserLibrary> libs = new LinkedList<UserLibrary>(
            Collections2.filter(new LinkedList<UserLibrary>(installedLibraries), Predicates.not(CONTRIBUTED)));
    return new LibraryList(libs);
}

From source file:com.facebook.buck.apple.project_generator.ProjectGenerator.java

private ImmutableList<TargetNode<?, ?>> rulesWithoutBundleLoader(Iterable<TargetNode<?, ?>> copiedRules,
        TargetNode<?, ?> bundleLoader) {
    return FluentIterable.from(copiedRules).filter(Predicates.not(bundleLoader::equals)).toList();
}