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.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.FrameCreationValidator.java

private void checkOtherLifelines(ISequenceEvent eventToCheck, Collection<ISequenceEvent> eventsToIgnore) {
    Range rangeToCheck = eventToCheck.getVerticalRange();
    for (Lifeline lifeline : sequenceEventsInCreationRange.keySet()) {
        Collection<ISequenceEvent> overlap = sequenceEventsInCreationRange.get(lifeline);
        // Dot check event to shift lifeline
        if (!overlap.contains(eventToCheck)) {
            for (ISequenceEvent otherLifelineEvent : Iterables.filter(overlap,
                    Predicates.not(Predicates.in(eventsToIgnore)))) {
                Range otherRange = otherLifelineEvent.getVerticalRange();
                Range intersection = otherRange.intersection(rangeToCheck);
                if (!intersection.equals(rangeToCheck) && !intersection.equals(otherRange)
                        && !intersection.isEmpty()) {
                    valid = false;/*from  ww  w.  j  av a 2s .  c  o  m*/
                }
            }
        }
    }
}

From source file:info.magnolia.setup.for4_5.UpdateSecurityFilterClientCallbacksConfiguration.java

/**
 * Checks if the given node has other properties than those specified by the ignoredProperties parameter.
 *///from  w  w  w  .  j  a  va2 s  . c o m
private void checkRemainingProperties(InstallContext ctx, Content source, String... ignoredProperties) {
    final Set<String> ignoredPropsSet = Sets.newHashSet(ignoredProperties);
    final Collection<NodeData> allProps = source.getNodeDataCollection();
    final Iterable<String> allPropsNames = Iterables.transform(allProps, new Function<NodeData, String>() {
        @Override
        public String apply(NodeData from) {
            return from.getName();
        }
    });
    final Iterable<String> remaining = Iterables.filter(allPropsNames,
            Predicates.not(Predicates.in(ignoredPropsSet)));
    if (!Iterables.isEmpty(remaining)) {
        log.warn(source.getHandle() + " has the following unknown properties which were not copied: "
                + remaining);
        wereWeAbleToUpdateEverything = false;
    }
}

From source file:com.google.devtools.build.lib.skyframe.TargetPatternPhaseFunction.java

/**
 * Interpret the command-line arguments.
 *
 * @param options the command-line arguments in structured form
 *///w  w  w . ja v  a  2s.  c om
private static ResolvedTargets<Target> getTargetsToBuild(Environment env, TargetPatternList options)
        throws InterruptedException {
    List<SkyKey> patternSkyKeys = new ArrayList<>();
    for (TargetPatternSkyKeyOrException keyOrException : TargetPatternValue.keys(options.getTargetPatterns(),
            FilteringPolicies.FILTER_MANUAL, options.getOffset())) {
        try {
            patternSkyKeys.add(keyOrException.getSkyKey());
        } catch (TargetParsingException e) {
            // Skip.
        }
    }
    Map<SkyKey, ValueOrException<TargetParsingException>> resolvedPatterns = env
            .getValuesOrThrow(patternSkyKeys, TargetParsingException.class);
    if (env.valuesMissing()) {
        return null;
    }

    ResolvedTargets.Builder<Target> builder = ResolvedTargets.builder();
    for (SkyKey key : patternSkyKeys) {
        TargetPatternKey pattern = (TargetPatternKey) key.argument();
        TargetPatternValue value;
        try {
            value = (TargetPatternValue) resolvedPatterns.get(key).get();
        } catch (TargetParsingException e) {
            // TODO(ulfjack): Report to EventBus.
            String rawPattern = pattern.getPattern();
            String errorMessage = e.getMessage();
            env.getListener().handle(Event.error("Skipping '" + rawPattern + "': " + errorMessage));
            builder.setError();
            continue;
        }
        // TODO(ulfjack): This is terribly inefficient.
        ResolvedTargets<Target> asTargets = TestSuiteExpansionFunction.labelsToTargets(env,
                value.getTargets().getTargets(), value.getTargets().hasError());
        if (pattern.isNegative()) {
            builder.filter(Predicates.not(Predicates.in(asTargets.getTargets())));
        } else {
            builder.merge(asTargets);
        }
    }

    ResolvedTargets<Target> result = builder.filter(TargetUtils.tagFilter(options.getBuildTargetFilter()))
            .build();
    if (options.getCompileOneDependency()) {
        TargetProvider targetProvider = new EnvironmentBackedRecursivePackageProvider(env);
        try {
            return new CompileOneDependencyTransformer(targetProvider)
                    .transformCompileOneDependency(env.getListener(), result);
        } catch (MissingDepException e) {
            return null;
        } catch (TargetParsingException e) {
            env.getListener().handle(Event.error(e.getMessage()));
            return ResolvedTargets.failed();
        }
    }
    return result;
}

From source file:specminers.evaluation.JflapFileManipulator.java

private Set<String> getAllExpansionsForSequenceWithStarWildcard(String sequence) {
    Set<String> expansions = new HashSet<>();

    int wildcardIndex = sequence.indexOf("*");
    if (wildcardIndex == -1) {
        expansions.add(sequence);//from ww  w .ja v  a 2s.  co m
        return expansions;
    }

    int endIndexPreviousMethod = sequence.substring(0, wildcardIndex - 1).lastIndexOf(")");
    String beforeWildcardMethod = sequence.substring(0, endIndexPreviousMethod + 1);
    String afterWildcard = "";

    if (wildcardIndex < sequence.length() - 1) {
        afterWildcard = sequence.substring(wildcardIndex + 1);
    }

    String wildcardExpresion = sequence.substring(endIndexPreviousMethod + 1, wildcardIndex + 1).trim();
    String classWildcard = wildcardExpresion.substring(wildcardExpresion.lastIndexOf("."));
    String className = wildcardExpresion.replace(classWildcard, "");

    String classWildCardRegex = "^" + classWildcard.replace(".", "").replace("*", ".+") + "$";
    try {
        Class<?> cls = Class.forName(className);
        //List<Method> classMethods = Arrays.asList(cls.getMethods());
        Set<Method> classMethods = ReflectionUtils.getAllMethods(cls,
                Predicates.not(withModifier(Modifier.PRIVATE)));

        for (Method m : classMethods) {
            if (m.getName().matches(classWildCardRegex)) {
                String expansion = String.format("%s%s%s", beforeWildcardMethod, className + "." + m.getName(),
                        afterWildcard);
                expansions.add(expansion);
            }
        }

    } catch (ClassNotFoundException ex) {
        Logger.getLogger(JflapFileManipulator.class.getName()).log(Level.SEVERE, null, ex);
        // throw new RuntimeException(ex);
    }

    return expansions;
}

From source file:org.trancecode.xproc.XProcTestParser.java

private List<XdmNode> extractDocuments(final XdmNode node) {
    final List<XdmNode> documents = Lists.newLinkedList();
    final String href = node.getAttributeValue(XProcTestSuiteXmlModel.ATTRIBUTE_HREF);
    if (href != null) {
        documents.add(loadExternalDocument(href, node));
        LOG.trace("New external document");
    } else {//from w w w . j  av  a2s .c o m
        final Iterable<XdmNode> documentElements = SaxonAxis.childElements(node,
                XProcTestSuiteXmlModel.ELEMENT_DOCUMENT);
        if (Iterables.isEmpty(documentElements)) {
            final Iterable<XdmNode> nodes = Iterables.filter(SaxonAxis.childElements(node),
                    Predicates.not(SaxonPredicates.isAttribute()));
            if (Iterables.isEmpty(nodes)) {
                LOG.trace("New empty document");
                documents.add(Saxon.asDocumentNode(processor, nodes));
            } else {
                LOG.trace("New inline document");
                final XdmNode aNode = Saxon.asDocumentNode(processor, nodes);
                aNode.getUnderlyingNode().setSystemId(node.getBaseURI().toASCIIString());
                documents.add(aNode);
            }
        } else {
            for (final XdmNode documentNode : documentElements) {
                final String documentHref = documentNode
                        .getAttributeValue(XProcTestSuiteXmlModel.ATTRIBUTE_HREF);
                if (documentHref != null) {
                    LOG.trace("New external document: {}", documentHref);
                    documents.add(loadExternalDocument(documentHref, documentNode));
                } else {
                    LOG.trace("New wrapped document");
                    final Iterable<XdmNode> nodesWithoutAttributes = Iterables.filter(
                            SaxonAxis.childNodes(documentNode), Predicates.not(SaxonPredicates.isAttribute()));
                    documents.add(Saxon.asDocumentNode(processor, nodesWithoutAttributes));
                }
            }
        }
    }
    return documents;
}

From source file:org.apache.cassandra.io.sstable.SSTable.java

/**
 * Registers new custom components. Used by custom compaction strategies.
 * Adding a component for the second time is a no-op.
 * Don't remove this - this method is a part of the public API, intended for use by custom compaction strategies.
 * @param newComponents collection of components to be added
 *///from w  w w.  j a  va 2  s.c  om
public synchronized void addComponents(Collection<Component> newComponents) {
    Collection<Component> componentsToAdd = Collections2.filter(newComponents,
            Predicates.not(Predicates.in(components)));
    appendTOC(descriptor, componentsToAdd);
    components.addAll(componentsToAdd);
}

From source file:com.sri.ai.grinder.sgdpllt.library.Equality.java

/**
 * Assumes that first argument is an equality (with possibly more than two arguments) and returns a pair,
 * the first member of which is a set of the variables in the equality,
 * and the second member of which is a set of constants in the equality.
 *///w  ww . ja v a  2s .  c o  m
public static Pair<Set<Expression>, Set<Expression>> getVariablesListAndConstantsList(Expression equality,
        Context context) {
    Pair<Set<Expression>, Set<Expression>> result;
    Set<Expression> variables = new LinkedHashSet<Expression>();
    Set<Expression> constants = new LinkedHashSet<Expression>();
    Predicate<Expression> notIsConstant = Predicates.not(context.getIsUniquelyNamedConstantPredicate());
    Util.collectOrReturnFalseIfElementDoesNotFitEither(equality.getArguments(), variables, notIsConstant,
            constants, context.getIsUniquelyNamedConstantPredicate());
    result = Pair.make(variables, constants);
    return result;
}

From source file:org.eclipse.sirius.diagram.ui.business.api.helper.graphicalfilters.CollapseUpdater.java

/**
 * Remove filter of <code>element</code> and update (if needed) the bounds
 * of the GMF Node.// ww  w  .ja v a 2  s  . c  om
 * 
 * @param element
 *            The @link {@link DDiagramElement} to synchronized.
 * @param optionalNode
 *            The optional {@link Node} to synchronized. The GMF bounds are
 *            not update if there is no node (it is the case during the
 *            repair process).
 * @param kindOfFilter
 *            the kind of filter to add or remove ( {@link CollapseFilter}
 *            or {@link IndirectlyCollapseFilter}
 */
protected void removeGraphicalFilter(DDiagramElement element, Option<Node> optionalNode,
        Class<? extends CollapseFilter> kindOfFilter) {
    // Compute the expanded Bounds that will be used at the end if the node
    // is no more collapsed. This expanded bounds is computed now because
    // after removing all graphical filters is too late.
    Option<Bounds> optionalExpandedBounds;
    if (optionalNode.some()) {
        optionalExpandedBounds = getExpandedBounds(optionalNode.get(), element);
    } else {
        optionalExpandedBounds = Options.newNone();

    }
    if (kindOfFilter.equals(CollapseFilter.class)) {
        // Iterate on all CollapseFilter that are not
        // IndirectlyCollapseFilter
        for (CollapseFilter collapseApplication : Lists.newArrayList(
                Iterables.filter(Iterables.filter(element.getGraphicalFilters(), CollapseFilter.class),
                        Predicates.not(Predicates.instanceOf(IndirectlyCollapseFilter.class))))) {
            element.getGraphicalFilters().remove(collapseApplication);
        }
        removeFromChildrenIndirectlyCollapsedFilter(element);
    } else if (kindOfFilter.equals(IndirectlyCollapseFilter.class)) {
        for (IndirectlyCollapseFilter collapseApplication : Lists.newArrayList(
                Iterables.filter(element.getGraphicalFilters(), IndirectlyCollapseFilter.class))) {
            element.getGraphicalFilters().remove(collapseApplication);
        }
    }

    if (optionalNode.some()) {
        NodeQuery nodeQuery = new NodeQuery(optionalNode.get());
        // if the node have no more collapse filter after having remove the
        // last one, we expand it (if it's a bordered node only)
        if (!nodeQuery.isCollapsed() && nodeQuery.isBorderedNode()) {
            if (optionalExpandedBounds.some()) {
                optionalNode.get().setLayoutConstraint(optionalExpandedBounds.get());
            }
        }
    }
}

From source file:org.eclipse.sirius.diagram.sequence.business.internal.operation.SynchronizeISequenceEventsSemanticOrderingOperation.java

private List<EventEnd> getCompoundEnds(ISequenceEvent eventToUpdate, List<EventEnd> ends) {
    List<ISequenceEvent> compoundEvents = EventEndHelper.getCompoundEvents(eventToUpdate);
    Predicate<ISequenceEvent> isLogicallyInstantaneousNonReorderedEvent = new Predicate<ISequenceEvent>() {
        @Override/*  www .j av a  2  s . c  om*/
        public boolean apply(ISequenceEvent input) {
            return input.isLogicallyInstantaneous() && !reordered.contains(input);
        };
    };
    Iterable<ISequenceEvent> compoundEventsToReorder = Iterables.filter(compoundEvents,
            isLogicallyInstantaneousNonReorderedEvent);
    Iterable<EventEnd> nonReorderedEndsOfCompoundEvents = Iterables
            .concat(Iterables.transform(compoundEventsToReorder, EventEndHelper.EVENT_ENDS));
    Predicate<EventEnd> isCompoundEnd = Predicates.and(Predicates.instanceOf(SingleEventEnd.class),
            Predicates.not(Predicates.in(ends)));

    return Lists.newArrayList(Iterables.filter(nonReorderedEndsOfCompoundEvents, isCompoundEnd));
}

From source file:com.squareup.javapoet.Types.java

private static TypeVariable<?> get(javax.lang.model.type.TypeVariable mirror) {
    String name = mirror.asElement().getSimpleName().toString();

    TypeMirror upperBound = mirror.getUpperBound();
    FluentIterable<TypeMirror> bounds = FluentIterable.from(ImmutableList.of(upperBound));
    // Try to detect intersection types for Java 7 (Java 8+ has a new TypeKind for that)
    // Unfortunately, we can't put this logic into Types.get() as this heuristic only really works
    // in the context of a TypeVariable's upper bound.
    if (upperBound.getKind() == TypeKind.DECLARED) {
        TypeElement bound = (TypeElement) ((DeclaredType) upperBound).asElement();
        if (bound.getNestingKind() == NestingKind.ANONYMOUS) {
            // This is (likely) an intersection type.
            bounds = FluentIterable.from(ImmutableList.of(bound.getSuperclass())).append(bound.getInterfaces());
        }/*  w ww.  j a  v  a  2  s  .  c  om*/
    }
    Type[] types = bounds.transform(FOR_TYPE_MIRROR)
            .filter(Predicates.not(Predicates.<Type>equalTo(ClassName.OBJECT))).toArray(Type.class);
    return typeVariable(name, types);
}