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:fr.aliacom.obm.common.calendar.EventNotificationServiceImpl.java

private Collection<Attendee> filterAttendees(final Event event, Collection<Attendee> attendees) {
    return FluentIterable.from(attendees).filter(new Predicate<Attendee>() {
        @Override//from w w  w.  j a  v  a  2  s .c  o  m
        public boolean apply(Attendee attendee) {
            return !attendee.getEmail().equalsIgnoreCase(event.getOwnerEmail());
        }
    }).filter(Predicates.not(Predicates.instanceOf(ResourceAttendee.class))).toSet();
}

From source file:org.apache.cassandra.cql.QueryProcessor.java

private static 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:com.google.devtools.build.lib.rules.objc.ProtoSupport.java

private Iterable<Artifact> getFilteredProtos() {
    // Filter the well known types from being sent to be generated, as these protos have already
    // been generated and linked in libprotobuf.a.
    return Iterables.filter(attributes.getProtoFiles(),
            Predicates.not(Predicates.in(attributes.getWellKnownTypeProtos())));
}

From source file:co.cask.cdap.etl.common.guice.Types.java

private static Iterable<Type> filterUpperBounds(Iterable<Type> bounds) {
    return Iterables.filter(bounds, Predicates.not(Predicates.<Type>equalTo(Object.class)));
}

From source file:org.eclipse.sirius.diagram.sequence.business.internal.refresh.SequenceCanonicalSynchronizerAdapter.java

private Set<ISequenceEvent> getEventEndsAfterUpperRange(SequenceDiagram sequenceDiagram, Lifeline lifeline,
        int upperRange, Set<ISequenceEvent> sequenceEventToIgnores) {
    Set<ISequenceEvent> eventEndsAfterUpperRange = new TreeSet<ISequenceEvent>(new RangeComparator());
    Set<ISequenceEvent> allSequenceEventsInUpperRange = new SequenceDiagramQuery(sequenceDiagram)
            .getAllSequenceEventsUpperThan(upperRange);
    allSequenceEventsInUpperRange.removeAll(sequenceEventToIgnores);
    eventEndsAfterUpperRange.addAll(//from ww  w . j  a va  2  s . com
            Sets.filter(allSequenceEventsInUpperRange, Predicates.not(Predicates.instanceOf(Lifeline.class))));
    return eventEndsAfterUpperRange;
}

From source file:org.apache.brooklyn.entity.database.mysql.InitSlaveTaskBody.java

private ImmutableList<MySqlNode> getHealhtySlaves() {
    return FluentIterable.from(cluster.getMembers()).filter(Predicates.not(MySqlClusterUtils.IS_MASTER))
            .filter(EntityPredicates.attributeEqualTo(MySqlNode.SERVICE_UP, Boolean.TRUE))
            .filter(MySqlNode.class).toList();
}

From source file:com.palantir.atlasdb.transaction.impl.SnapshotTransaction.java

@Override
public Map<Cell, byte[]> get(String tableName, Set<Cell> cells) {
    Stopwatch watch = Stopwatch.createStarted();
    checkGetPreconditions(tableName);/*from ww  w .j a  va 2 s  .co  m*/
    if (Iterables.isEmpty(cells)) {
        return ImmutableMap.of();
    }

    Map<Cell, byte[]> result = Maps.newHashMap();
    SortedMap<Cell, byte[]> writes = writesByTable.get(tableName);
    if (writes != null) {
        for (Cell cell : cells) {
            if (writes.containsKey(cell)) {
                result.put(cell, writes.get(cell));
            }
        }
    }

    // We don't need to read any cells that were written locally.
    result.putAll(getFromKeyValueService(tableName, Sets.difference(cells, result.keySet())));

    if (perfLogger.isDebugEnabled()) {
        perfLogger.debug("get({}, {} cells) found {} cells (some possibly deleted), took {} ms", tableName,
                cells.size(), result.size(), watch.elapsed(TimeUnit.MILLISECONDS));
    }
    validateExternalAndCommitLocksIfNecessary(tableName);
    return Maps.filterValues(result, Predicates.not(Value.IS_EMPTY));
}

From source file:org.eclipse.sirius.diagram.sequence.business.internal.refresh.SequenceCanonicalSynchronizerAdapter.java

private Set<ISequenceEvent> getEventEndsOnUpperRange(SequenceDiagram sequenceDiagram, Lifeline lifeline,
        int upperRange, Set<ISequenceEvent> sequenceEventToIgnores) {
    Set<ISequenceEvent> eventEndsOnUpperRange = new TreeSet<ISequenceEvent>(new RangeComparator());
    Set<ISequenceEvent> allSequenceEventsOnRange = new SequenceDiagramQuery(sequenceDiagram)
            .getAllSequenceEventsOn(upperRange);
    allSequenceEventsOnRange.removeAll(sequenceEventToIgnores);
    eventEndsOnUpperRange.addAll(/* w w w  . j a v a 2 s  . c om*/
            Sets.filter(allSequenceEventsOnRange, Predicates.not(Predicates.instanceOf(Lifeline.class))));
    return eventEndsOnUpperRange;
}

From source file:forge.ai.AiController.java

public Card chooseBestLandToPlay(CardCollection landList) {
    if (landList.isEmpty()) {
        return null;
    }// www  .j  a  v  a2  s.co m
    //Skip reflected lands.
    CardCollection unreflectedLands = new CardCollection(landList);
    for (Card l : landList) {
        if (l.isReflectedLand()) {
            unreflectedLands.remove(l);
        }
    }
    if (!unreflectedLands.isEmpty()) {
        landList = unreflectedLands;
    }

    CardCollection nonLandsInHand = CardLists.filter(player.getCardsIn(ZoneType.Hand),
            Predicates.not(CardPredicates.Presets.LANDS));

    //try to skip lands that enter the battlefield tapped
    if (!nonLandsInHand.isEmpty()) {
        CardCollection nonTappeddLands = new CardCollection();
        for (Card land : landList) {
            // Is this the best way to check if a land ETB Tapped?
            if (land.hasSVar("ETBTappedSVar")) {
                continue;
            }
            // Glacial Fortress and friends
            if (land.hasSVar("ETBCheckSVar")
                    && CardFactoryUtil.xCount(land, land.getSVar("ETBCheckSVar")) == 0) {
                continue;
            }
            nonTappeddLands.add(land);
        }
        if (!nonTappeddLands.isEmpty()) {
            landList = nonTappeddLands;
        }
    }

    // Choose first land to be able to play a one drop
    if (player.getLandsInPlay().isEmpty()) {
        CardCollection oneDrops = CardLists.filter(nonLandsInHand, CardPredicates.hasCMC(1));
        for (int i = 0; i < MagicColor.WUBRG.length; i++) {
            byte color = MagicColor.WUBRG[i];
            if (!CardLists.filter(oneDrops, CardPredicates.isColor(color)).isEmpty()) {
                for (Card land : landList) {
                    if (land.getType().hasSubtype(MagicColor.Constant.BASIC_LANDS.get(i))) {
                        return land;
                    }
                    for (final SpellAbility m : ComputerUtilMana.getAIPlayableMana(land)) {
                        AbilityManaPart mp = m.getManaPart();
                        if (mp.canProduce(MagicColor.toShortString(color), m)) {
                            return land;
                        }
                    }
                }
            }
        }
    }

    //play lands with a basic type that is needed the most
    final CardCollectionView landsInBattlefield = player.getCardsIn(ZoneType.Battlefield);
    final List<String> basics = new ArrayList<String>();

    // what types can I go get?
    for (final String name : MagicColor.Constant.BASIC_LANDS) {
        if (!CardLists.getType(landList, name).isEmpty()) {
            basics.add(name);
        }
    }
    if (!basics.isEmpty()) {
        // Which basic land is least available
        int minSize = Integer.MAX_VALUE;
        String minType = null;

        for (String b : basics) {
            final int num = CardLists.getType(landsInBattlefield, b).size();
            if (num < minSize) {
                minType = b;
                minSize = num;
            }
        }

        if (minType != null) {
            landList = CardLists.getType(landList, minType);
        }

        // pick dual lands if available
        if (Iterables.any(landList, Predicates.not(CardPredicates.Presets.BASIC_LANDS))) {
            landList = CardLists.filter(landList, Predicates.not(CardPredicates.Presets.BASIC_LANDS));
        }
    }
    return landList.get(0);
}

From source file:clocker.docker.entity.DockerInfrastructureImpl.java

/**
 * De-register our {@link DockerLocation} and its children.
 *//*from w w  w  .  j  av  a2  s .  c  o m*/
@Override
public void stop() {
    sensors().set(SERVICE_UP, Boolean.FALSE);
    ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING);
    Duration timeout = config().get(SHUTDOWN_TIMEOUT);

    deleteLocation();

    // Shutdown the Registry if configured
    if (config().get(DOCKER_SHOULD_START_REGISTRY)) {
        Entity registry = sensors().get(DOCKER_IMAGE_REGISTRY);
        DockerUtils.stop(this, registry, Duration.THIRTY_SECONDS);
    }

    // Find all applications and stop, blocking for up to five minutes until ended
    try {
        Iterable<Entity> entities = Iterables.filter(getManagementContext().getEntityManager().getEntities(),
                Predicates.and(DockerUtils.sameInfrastructure(this),
                        Predicates.not(EntityPredicates.applicationIdEqualTo(getApplicationId()))));
        Set<Application> applications = ImmutableSet
                .copyOf(Iterables.transform(entities, new Function<Entity, Application>() {
                    @Override
                    public Application apply(Entity input) {
                        return input.getApplication();
                    }
                }));
        LOG.debug("Stopping applications: {}", Iterables.toString(applications));
        Entities.invokeEffectorList(this, applications, Startable.STOP).get(timeout);
    } catch (Exception e) {
        LOG.warn("Error stopping applications", e);
    }

    // Stop all Docker hosts in parallel
    try {
        DynamicCluster hosts = getDockerHostCluster();
        LOG.debug("Stopping hosts: {}", Iterables.toString(hosts.getMembers()));
        Entities.invokeEffectorList(this, hosts.getMembers(), Startable.STOP).get(timeout);
    } catch (Exception e) {
        LOG.warn("Error stopping hosts", e);
    }

    ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPED);
}