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.business.internal.operation.SynchronizeISequenceEventsSemanticOrderingOperation.java

private Set<EventEnd> selectEndsToIgnore(ISequenceEvent ise, List<EventEnd> endsBySemanticOrder,
        final List<EventEnd> iseEnds, final List<EventEnd> compoundEnds) {
    final Iterable<ISequenceEvent> movedElements = Iterables.filter(allElementsToReorder,
            Predicates.not(Predicates.in(reordered)));
    final Set<EObject> semanticLinked = Sets.newHashSet(Iterables.filter(
            Iterables.transform(movedElements, ISequenceElement.SEMANTIC_TARGET), Predicates.notNull()));
    final Predicate<EObject> isLinkedSubEventEnd = new Predicate<EObject>() {
        @Override//ww w  .  j a va2s . c  o m
        public boolean apply(EObject input) {
            return semanticLinked.contains(input);
        }
    };

    final Set<EObject> semanticDescendants = Sets
            .newHashSet(Iterables.filter(Iterables.transform(new ISequenceEventQuery(ise).getAllDescendants(),
                    ISequenceElement.SEMANTIC_TARGET), Predicates.notNull()));
    final Predicate<EObject> isSemanticSubEventEnd = new Predicate<EObject>() {
        @Override
        public boolean apply(EObject input) {
            return semanticDescendants.contains(input);
        }
    };

    Predicate<EventEnd> toIgnore = new Predicate<EventEnd>() {
        @Override
        public boolean apply(EventEnd input) {
            return !iseEnds.contains(input) && (Iterables.any(EventEndHelper.getSemanticEvents(input),
                    Predicates.or(isSemanticSubEventEnd, isLinkedSubEventEnd)) || compoundEnds.contains(input));
        }
    };
    HashSet<EventEnd> newHashSet = Sets.newHashSet(Iterables.filter(endsBySemanticOrder, toIgnore));
    return newHashSet;
}

From source file:org.trancecode.xproc.step.Step.java

public Iterable<Port> getInputPorts(final boolean includeParameterPorts) {
    if (includeParameterPorts) {
        return Iterables.filter(ports.values(), PortPredicates.isInputPort());
    } else {//w  ww  . j a  va2  s.c  o  m
        return Iterables.filter(ports.values(),
                Predicates.and(PortPredicates.isInputPort(), Predicates.not(PortPredicates.isParameterPort())));
    }
}

From source file:org.eclipse.sirius.diagram.sequence.business.internal.layout.horizontal.SequenceHorizontalLayout.java

private int getOrComputeMaxChildrenDepth(AbstractFrame frame, Collection<AbstractFrame> framesToIgnore) {
    int children = 0;
    if (!frameChildrenDepths.containsKey(frame)) {
        Collection<Lifeline> frameCoverage = coverage.get(frame);
        Range frameRange = ranges.get(frame);
        for (AbstractFrame potentialChild : Iterables.filter(frames,
                Predicates.not(Predicates.in(framesToIgnore)))) {
            Collection<Lifeline> potentialCoverage = coverage.get(potentialChild);
            Range potentialRange = ranges.get(potentialChild);

            if (frame != potentialChild && frameCoverage.containsAll(potentialCoverage)
                    && frameRange.includes(potentialRange)) {
                ArrayList<AbstractFrame> newArrayList = Lists.newArrayList(framesToIgnore);
                newArrayList.add(potentialChild);
                children = Math.max(children, 1 + getOrComputeMaxChildrenDepth(potentialChild, newArrayList));
            }//from   w  w w .ja  v  a 2  s.  c o  m
        }
        frameChildrenDepths.put(frame, children);
    } else {
        children = frameChildrenDepths.get(frame);
    }
    return children;
}

From source file:org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl.ThreeWayComparisonGroupProvider.java

/**
 * {@inheritDoc}// w w  w . jav a 2  s.co  m
 * 
 * @see org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl.AbstractBuildingDifferenceGroupProvider#buildGroups(org.eclipse.emf.compare.Comparison)
 */
@Override
protected Collection<? extends IDifferenceGroup> buildGroups(Comparison comparison2) {
    Adapter adapter = EcoreUtil.getAdapter(getComparison().eAdapters(), SideLabelProvider.class);

    final String leftLabel, rightLabel;
    if (adapter instanceof SideLabelProvider) {
        SideLabelProvider labelProvider = (SideLabelProvider) adapter;
        leftLabel = labelProvider.getLeftLabel();
        rightLabel = labelProvider.getRightLabel();
    } else {
        leftLabel = EMFCompareRCPUIMessages.getString("ThreeWayComparisonGroupProvider.left.label"); //$NON-NLS-1$
        rightLabel = EMFCompareRCPUIMessages.getString("ThreeWayComparisonGroupProvider.right.label"); //$NON-NLS-1$
    }

    final BasicDifferenceGroupImpl conflicts = new ConflictsGroupImpl(getComparison(),
            hasConflict(ConflictKind.REAL, ConflictKind.PSEUDO),
            EMFCompareRCPUIMessages.getString("ThreeWayComparisonGroupProvider.conflicts.label"), //$NON-NLS-1$
            getCrossReferenceAdapter());
    conflicts.buildSubTree();

    final BasicDifferenceGroupImpl leftSide = new BasicDifferenceGroupImpl(getComparison(),
            Predicates.and(fromSide(DifferenceSource.LEFT),
                    Predicates.not(hasConflict(ConflictKind.REAL, ConflictKind.PSEUDO))),
            leftLabel, getCrossReferenceAdapter());
    leftSide.buildSubTree();

    final BasicDifferenceGroupImpl rightSide = new BasicDifferenceGroupImpl(getComparison(),
            Predicates.and(fromSide(DifferenceSource.RIGHT),
                    Predicates.not(hasConflict(ConflictKind.REAL, ConflictKind.PSEUDO))),
            rightLabel, getCrossReferenceAdapter());
    rightSide.buildSubTree();

    return ImmutableList.of(conflicts, leftSide, rightSide);
}

From source file:brooklyn.networking.sdn.mesos.CalicoModuleImpl.java

@Override
public void provisionNetwork(VirtualNetwork network) {
    String networkId = network.sensors().get(VirtualNetwork.NETWORK_ID);
    Cidr subnetCidr = SdnUtils.provisionNetwork(this, network);
    boolean ipip = config().get(CalicoModule.USE_IPIP);
    boolean nat = config().get(CalicoModule.USE_NAT);
    String addPool = String.format("calicoctl pool add %s %s %s", subnetCidr, ipip ? "--ipip" : "",
            nat ? "--nat-outgoing" : "");
    MesosSlave slave = (MesosSlave) getMesosCluster().sensors().get(MesosCluster.MESOS_SLAVES).getMembers()
            .iterator().next();/*from w  w  w  .  j  a  v  a2s . co m*/
    execCalicoCommand(slave, addPool);

    // Create a DynamicGroup with all attached entities
    EntitySpec<DynamicGroup> networkSpec = EntitySpec.create(DynamicGroup.class)
            .configure(DynamicGroup.ENTITY_FILTER,
                    Predicates.and(
                            Predicates.not(Predicates.or(Predicates.instanceOf(MarathonTask.class),
                                    Predicates.instanceOf(DelegateEntity.class))),
                            MesosUtils.sameCluster(getMesosCluster()), SdnUtils.attachedToNetwork(networkId)))
            .displayName(network.getDisplayName());
    DynamicGroup subnet = sensors().get(SDN_APPLICATIONS).addMemberChild(networkSpec);
    subnet.sensors().set(VirtualNetwork.NETWORK_ID, networkId);
    network.sensors().set(VirtualNetwork.NETWORKED_APPLICATIONS, subnet);

    sensors().get(SDN_NETWORKS).addMember(network);
}

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

/**
 * Interpret test target labels from the command-line arguments and return the corresponding set
 * of targets, handling the filter flags, and expanding test suites.
 *
 * @param targetPatterns the list of command-line target patterns specified by the user
 * @param testFilter the test filter/*from  www  . ja v  a 2s. co  m*/
 */
private static ResolvedTargets<Target> determineTests(Environment env, List<String> targetPatterns,
        String offset, TestFilter testFilter) throws InterruptedException {
    List<SkyKey> patternSkyKeys = new ArrayList<>();
    for (TargetPatternSkyKeyOrException keyOrException : TargetPatternValue.keys(targetPatterns,
            FilteringPolicies.FILTER_TESTS, offset)) {
        try {
            patternSkyKeys.add(keyOrException.getSkyKey());
        } catch (TargetParsingException e) {
            // Skip.
        }
    }
    Map<SkyKey, ValueOrException<TargetParsingException>> resolvedPatterns = env
            .getValuesOrThrow(patternSkyKeys, TargetParsingException.class);
    if (env.valuesMissing()) {
        return null;
    }

    List<SkyKey> expandedSuiteKeys = new ArrayList<>();
    for (SkyKey key : patternSkyKeys) {
        TargetPatternValue value;
        try {
            value = (TargetPatternValue) resolvedPatterns.get(key).get();
        } catch (TargetParsingException e) {
            // Skip.
            continue;
        }
        expandedSuiteKeys.add(TestSuiteExpansionValue.key(value.getTargets().getTargets()));
    }
    Map<SkyKey, SkyValue> expandedSuites = env.getValues(expandedSuiteKeys);
    if (env.valuesMissing()) {
        return null;
    }

    ResolvedTargets.Builder<Target> testTargetsBuilder = ResolvedTargets.builder();
    for (SkyKey key : patternSkyKeys) {
        TargetPatternKey pattern = (TargetPatternKey) key.argument();
        TargetPatternValue value;
        try {
            value = (TargetPatternValue) resolvedPatterns.get(key).get();
        } catch (TargetParsingException e) {
            // This was already reported in getTargetsToBuild (maybe merge the two code paths?).
            continue;
        }

        TestSuiteExpansionValue expandedSuitesValue = (TestSuiteExpansionValue) expandedSuites
                .get(TestSuiteExpansionValue.key(value.getTargets().getTargets()));
        if (pattern.isNegative()) {
            ResolvedTargets<Target> negativeTargets = expandedSuitesValue.getTargets();
            testTargetsBuilder.filter(Predicates.not(Predicates.in(negativeTargets.getTargets())));
            testTargetsBuilder.mergeError(negativeTargets.hasError());
        } else {
            ResolvedTargets<Target> positiveTargets = expandedSuitesValue.getTargets();
            testTargetsBuilder.addAll(positiveTargets.getTargets());
            testTargetsBuilder.mergeError(positiveTargets.hasError());
        }
    }
    testTargetsBuilder.filter(testFilter);
    return testTargetsBuilder.build();
}

From source file:io.crate.test.integration.CrateTestCluster.java

/**
 * Returns a node client to random node but not the master. This method will fail if no non-master client is available.
 *//*from www .ja  va2 s.c  o  m*/
public synchronized Client nonMasterClient() {
    ensureOpen();
    NodeAndClient randomNodeAndClient = getRandomNodeAndClient(
            Predicates.not(new MasterNodePredicate(getMasterName())));
    if (randomNodeAndClient != null) {
        return randomNodeAndClient.nodeClient(); // ensure node client non-master is requested
    }
    Assert.fail("No non-master client found");
    return null; // can't happen
}

From source file:de.iteratec.iteraplan.presentation.dialog.common.model.businessmapping.BusinessMappingsComponentModel.java

/**
 * Updates the business mapping model with new business mappings calculated by the cartesian
 * product of the given {@link BusinessProcess}, {@link BusinessUnit} and {@link Product} lists.
 *//*from   w w w . j ava  2  s.co m*/
List<BusinessMapping> updateClusterPartsWithNewBusinessMapping(BusinessMappingItems bmi) {
    final BusinessMappingStrategy strategy = BusinessMappingStrategyFactory.getStrategyFor(source.getClass());

    strategy.validate(bmi);

    final List<BusinessMapping> businessMappings = strategy.createBusinessMappings(bmi);
    final List<BusinessMapping> existingMappings = this.findExistingBusinessMappings(businessMappings,
            strategy);
    final Iterable<BusinessMapping> newMappings = Iterables.filter(businessMappings,
            Predicates.not(Predicates.in(existingMappings)));

    for (BusinessMapping businessMapping : newMappings) {
        strategy.addOwningEntity(businessMapping, source);

        final SingleBusinessMappingComponentModelPart covPart = new SingleBusinessMappingComponentModelPart(
                businessMapping, getComponentMode());
        covPart.initializeFrom(this.bmiSorted);
        final C clusterElementFromMapping = clusterElementRetriever
                .getClusterElementFromMapping(businessMapping);
        final ClusterComponentModelPart<T, C> clusterPart = getOrCreateClusterPart(clusterElementFromMapping);
        clusterPart.addMappingPart(covPart);
    }

    if (Iterables.isEmpty(newMappings) && existingMappings.isEmpty()) {
        // the user tried to add topLevelElements only -> throw an exception
        throw new IteraplanBusinessException(IteraplanErrorMessages.CANNOT_ADD_INVALID_BUSINESS_MAPPINGS);
    }

    return existingMappings;
}

From source file:clocker.docker.location.DockerContainerLocation.java

@Override
public int copyTo(Map<String, ?> props, File src, String destination) {
    Map<String, ?> nonPortProps = Maps.filterKeys(props, Predicates.not(Predicates.containsPattern("port")));
    boolean entitySsh = Boolean.TRUE.equals(entity.config().get(DockerContainer.DOCKER_USE_SSH));
    boolean dockerSsh = Boolean.TRUE.equals(getOwner().config().get(DockerContainer.DOCKER_USE_SSH));
    if (entitySsh && dockerSsh) {
        return super.copyTo(nonPortProps, src, destination);
    } else {//from ww w  .j  a va2  s.co m
        String tmp = Os.mergePaths("/tmp", Joiner.on('-').join(dockerContainer.getId(),
                Urls.getBasename(destination), Strings.makeRandomId(4)));
        hostMachine.copyTo(nonPortProps, src, tmp);
        copyFile(tmp, destination);
        return 0;
    }
}

From source file:org.sosy_lab.cpachecker.core.algorithm.pdr.transition.Blocks.java

/**
 * Combine the reached sets of the given blocks and insert their states into
 * the given target reached set.//ww w. ja v a2 s  . c om
 *
 * @param pBlocks the blocks. The order of the blocks is expected to be
 * 'forward', e.g. from the program entry to a target state.
 *
 * @param pTargetReachedSet the target reached set.
 */
public static void combineReachedSets(Iterable<Block> pBlocks, ReachedSet pTargetReachedSet) {
    if (Iterables.isEmpty(pBlocks)) {
        return;
    }

    AbstractState previousState = null;
    ARGState argPreviousState = null;
    List<Iterable<StateWithPrecision>> blockStates = new ArrayList<>();
    for (Block block : pBlocks) {
        ReachedSet reachedSet = block.getReachedSet();
        AbstractState firstState = block.getPredecessor();

        final AbstractState removed;
        if (argPreviousState == null) {
            removed = null;
        } else {
            ARGState argFirstState = AbstractStates.extractStateByType(firstState, ARGState.class);

            Preconditions
                    .checkArgument(!Sets
                            .intersection(
                                    FluentIterable.from(AbstractStates.extractLocations(argPreviousState))
                                            .toSet(),
                                    FluentIterable.from(AbstractStates.extractLocations(argFirstState)).toSet())
                            .isEmpty(), "Blocks must connect.");

            if (block.getDirection() == AnalysisDirection.FORWARD) {
                for (ARGState childOfFirstState : argFirstState.getChildren()) {
                    childOfFirstState.addParent(argPreviousState);
                }
                argFirstState.removeFromARG();
                removed = firstState;
            } else {
                for (ARGState childOfPreviousState : argPreviousState.getChildren()) {
                    childOfPreviousState.addParent(argFirstState);
                }
                argPreviousState.removeFromARG();
                removed = argPreviousState;
            }
        }

        Iterable<StateWithPrecision> remainingStates = FluentIterable.from(reachedSet)
                .filter(Predicates.not(Predicates.equalTo(removed)))
                .filter(as -> !AbstractStates.extractStateByType(as, ARGState.class).isDestroyed())
                .transform(as -> new StateWithPrecision(as, reachedSet.getPrecision(as)));
        blockStates.add(remainingStates);

        previousState = block.getSuccessor();
        argPreviousState = AbstractStates.extractStateByType(previousState, ARGState.class);
    }
    ListIterator<Iterable<StateWithPrecision>> blockStatesIterator = blockStates
            .listIterator(blockStates.size());
    while (blockStatesIterator.hasPrevious()) {
        for (StateWithPrecision stateWithPrecision : blockStatesIterator.previous()) {
            pTargetReachedSet.add(stateWithPrecision.state, stateWithPrecision.precision);
            pTargetReachedSet.removeOnlyFromWaitlist(stateWithPrecision.state);
        }
    }
}