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.cloud.bigtable.dataflowimport.HBaseResultToMutationFn.java

private Put processRowWithDeleteMarkers(byte[] rowKey, List<Cell> cells) throws IOException {
    Put put = new Put(rowKey);
    // Group cells by column family, since DeleteMarkers do not apply across families.
    Map<String, Collection<Cell>> dataCellsByFamilyMap = Multimaps
            .index(Iterables.filter(cells, Predicates.not(IS_DELETE_MARKER_FILTER)), COLUMN_FAMILY_EXTRACTOR)
            .asMap();/*from   w ww . ja  v  a 2  s  . c om*/
    Map<String, Collection<Cell>> deleteMarkersByFamilyMap = Multimaps
            .index(Iterables.filter(cells, IS_DELETE_MARKER_FILTER), COLUMN_FAMILY_EXTRACTOR).asMap();
    for (Map.Entry<String, Collection<Cell>> e : dataCellsByFamilyMap.entrySet()) {
        processOneColumnFamily(put, e.getValue(), deleteMarkersByFamilyMap.get(e.getKey()));
    }
    return put;
}

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

private void processNode(final XdmNode templateNode, final XdmNode sourceNode, final StepInput input,
        final SaxonBuilder builder, final Processor processor, final Map<QName, String> parameters) {
    assert templateNode != null;
    assert input != null;
    assert builder != null;
    assert processor != null;

    final Iterable<XdmNode> fullNodesList = Iterables.filter(SaxonAxis.childNodes(templateNode), XdmNode.class);
    final Iterable<XdmNode> filteredNodesList = Iterables.filter(fullNodesList,
            Predicates.not(SaxonPredicates.isIgnorableWhitespace()));

    for (final XdmItem currentItem : filteredNodesList) {
        assert !currentItem.isAtomicValue();

        final XdmNode itemAsNode = (XdmNode) currentItem;
        final XdmNodeKind nodeKind = itemAsNode.getNodeKind();

        if (nodeKind == XdmNodeKind.ATTRIBUTE || nodeKind == XdmNodeKind.COMMENT
                || nodeKind == XdmNodeKind.PROCESSING_INSTRUCTION || nodeKind == XdmNodeKind.TEXT) {
            final String nodeValue = itemAsNode.getStringValue();
            final QName nodeName = itemAsNode.getNodeName();
            final String evaluatedString = evaluateString(nodeValue, sourceNode, input, nodeKind, parameters);

            switch (nodeKind) {
            case ATTRIBUTE:
                builder.attribute(nodeName, evaluatedString);
                break;
            case TEXT:
                builder.raw(evaluatedString, processor);
                break;
            case COMMENT:
                builder.comment(evaluatedString);
                break;
            case PROCESSING_INSTRUCTION:
                builder.processingInstruction(nodeName.toString(), evaluatedString);
                break;
            default:
                throw new PipelineException("unhandled node kind");
            }//from   w  w w  . j av  a  2  s .  c o  m
        } else {
            if (nodeKind == XdmNodeKind.ELEMENT) {
                builder.startElement(itemAsNode.getNodeName());
                processNode(itemAsNode, sourceNode, input, builder, processor, parameters);
                builder.endElement();
            } else {
                throw new PipelineException("unhandled node kind");
            }
        }
    }
}

From source file:org.opendaylight.yangtools.yang.data.impl.schema.tree.ChoiceModificationStrategy.java

ChoiceModificationStrategy(final ChoiceSchemaNode schemaNode, final DataTreeConfiguration treeConfig) {
    super(ChoiceNode.class, treeConfig);

    final Builder<PathArgument, ModificationApplyOperation> childBuilder = ImmutableMap.builder();
    final Builder<PathArgument, CaseEnforcer> enforcerBuilder = ImmutableMap.builder();
    for (final ChoiceCaseNode caze : schemaNode.getCases()) {
        final CaseEnforcer enforcer = CaseEnforcer.forTree(caze, treeConfig);
        if (enforcer != null) {
            for (final Entry<NodeIdentifier, DataSchemaNode> e : enforcer.getChildEntries()) {
                childBuilder.put(e.getKey(), SchemaAwareApplyOperation.from(e.getValue(), treeConfig));
                enforcerBuilder.put(e.getKey(), enforcer);
            }/*from  ww  w. j av a  2 s. co m*/
            for (final Entry<AugmentationIdentifier, AugmentationSchema> e : enforcer
                    .getAugmentationEntries()) {
                childBuilder.put(e.getKey(),
                        new AugmentationModificationStrategy(e.getValue(), caze, treeConfig));
                enforcerBuilder.put(e.getKey(), enforcer);
            }
        }
    }
    childNodes = childBuilder.build();
    caseEnforcers = enforcerBuilder.build();

    final Map<CaseEnforcer, Collection<CaseEnforcer>> exclusionsBuilder = new HashMap<>();
    for (final CaseEnforcer e : caseEnforcers.values()) {
        exclusionsBuilder.put(e, ImmutableList
                .copyOf(Collections2.filter(caseEnforcers.values(), Predicates.not(Predicates.equalTo(e)))));
    }
    exclusions = ImmutableMap.copyOf(exclusionsBuilder);
}

From source file:specminers.evaluation.PradelRefSpecsExtender.java

static Set<String> getAllMethodsViaJavaReflection(String fullClassName) {
    try {/*w  ww.j a v a 2 s  .  co  m*/
        Class<?> cls = Class.forName(fullClassName);
        //List<Method> classMethods = Arrays.asList(cls.getMethods());
        Set<Method> classMethods = ReflectionUtils.getAllMethods(cls,
                Predicates.not(withModifier(Modifier.PUBLIC)));

        Set<String> signatures = classMethods.stream()
                .map(m -> String.format("%s.%s()", fullClassName, m.getName())).collect(Collectors.toSet());

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

From source file:org.napile.compiler.lang.resolve.calls.ResolutionTaskHolder.java

public List<ResolutionTask<D, F>> getTasks() {
    if (tasks == null) {
        tasks = Lists.newArrayList();/*from  w  ww  . j  a  v  a 2s  . co m*/
        List<Collection<ResolutionCandidate<D>>> candidateList = Lists.newArrayList();
        // If the call is of the form super.foo(), it can actually be only a member
        // But  if there's no appropriate member, we would like to report that super cannot be a receiver for an extension
        // Thus, put members first
        if (TaskPrioritizer.getReceiverSuper(basicResolutionContext.call.getExplicitReceiver()) != null) {
            candidateList.addAll(members);
            candidateList.addAll(localExtensions);
        } else {
            candidateList.addAll(localExtensions);
            candidateList.addAll(members);
        }
        candidateList.addAll(nonLocalExtensions);

        for (Predicate<ResolutionCandidate<D>> visibilityStrategy : Lists.newArrayList(visibleStrategy,
                Predicates.not(visibleStrategy))) {
            for (Collection<ResolutionCandidate<D>> candidates : candidateList) {
                Collection<ResolutionCandidate<D>> filteredCandidates = Collections2.filter(candidates,
                        visibilityStrategy);
                if (!filteredCandidates.isEmpty()) {
                    tasks.add(new ResolutionTask<D, F>(filteredCandidates, reference, basicResolutionContext));
                }
            }
        }
    }
    return tasks;
}

From source file:org.jclouds.googlecomputeengine.compute.functions.InstanceInZoneToNodeMetadata.java

@Override
public NodeMetadata apply(InstanceInZone instanceInZone) {
    Instance input = instanceInZone.getInstance();

    String group = groupFromMapOrName(input.getMetadata().getItems(), input.getName(), nodeNamingConvention);
    FluentIterable<String> tags = FluentIterable.from(input.getTags().getItems());
    if (group != null) {
        tags = tags.filter(Predicates.not(firewallTagNamingConvention.get(group).isFirewallTag()));
    }//from   w  ww  .j  ava2 s.  c om

    NodeMetadataBuilder builder = new NodeMetadataBuilder();

    builder.id(SlashEncodedIds.fromTwoIds(
            checkNotNull(locations.get().get(input.getZone()), "location for %s", input.getZone()).getId(),
            input.getName()).slashEncode()).name(input.getName()).providerId(input.getId())
            .hostname(input.getName())
            .location(checkNotNull(locations.get().get(input.getZone()), "location for %s", input.getZone()))
            .hardware(hardwares.get().get(input.getMachineType()))
            .status(toPortableNodeStatus.get(input.getStatus())).tags(tags).uri(input.getSelfLink())
            .userMetadata(input.getMetadata().getItems()).group(group)
            .privateAddresses(collectPrivateAddresses(input)).publicAddresses(collectPublicAddresses(input));

    if (input.getMetadata().getItems().containsKey(GCE_IMAGE_METADATA_KEY)) {
        try {
            URI imageUri = URI.create(input.getMetadata().getItems().get(GCE_IMAGE_METADATA_KEY));

            Map<URI, ? extends Image> imagesMap = images.get();

            Image image = checkNotNull(imagesMap.get(imageUri), "no image for %s. images: %s", imageUri,
                    imagesMap.values());
            builder.imageId(image.getId());
        } catch (IllegalArgumentException e) {
            // Swallow any exception here - it just means we don't actually have a valid image URI, so we skip it.
        }
    }

    return builder.build();
}

From source file:com.twitter.bazel.checkstyle.CppCheckstyle.java

@SuppressWarnings("unchecked")
private static Collection<String> getSourceFiles(String extraActionFile) {

    ExtraActionInfo info = ExtraActionUtils.getExtraActionInfo(extraActionFile);
    CppCompileInfo cppInfo = info.getExtension(CppCompileInfo.cppCompileInfo);

    return Collections2.filter(cppInfo.getSourcesAndHeadersList(),
            Predicates.and(Predicates.not(Predicates.containsPattern("3rdparty/")),
                    Predicates.not(Predicates.containsPattern("config/heron-config.h")),
                    Predicates.not(Predicates.containsPattern(".*pb.h$")),
                    Predicates.not(Predicates.containsPattern(".*pb.cc$"))));
}

From source file:forge.game.GameFormat.java

private Predicate<PaperCard> buildFilterRules() {
    final Predicate<PaperCard> banNames = Predicates.not(IPaperCard.Predicates.names(this.bannedCardNames_ro));
    if (this.allowedSetCodes_ro.isEmpty()) {
        return banNames;
    }/*from  w ww .  j  a  v a  2s .  c o m*/
    return Predicates.and(banNames,
            StaticData.instance().getCommonCards().wasPrintedInSets(this.allowedSetCodes_ro));
}

From source file:com.palantir.atlasdb.keyvalue.impl.RowResults.java

public static Iterator<RowResult<byte[]>> filterDeletedColumnsAndEmptyRows(
        final Iterator<RowResult<byte[]>> it) {
    Iterator<RowResult<byte[]>> purgeDeleted = Iterators.transform(it,
            createFilterColumnValues(Predicates.not(Value.IS_EMPTY)));
    return Iterators.filter(purgeDeleted, Predicates.not(RowResults.<byte[]>createIsEmptyPredicate()));
}

From source file:org.locationtech.geogig.storage.memory.HeapRefDatabase.java

/**
 * @return all known references under the "refs" namespace (i.e. not top level ones like HEAD,
 *         etc), key'ed by ref name/*from   w ww.  j a v a2 s .  co  m*/
 */
@Override
public Map<String, String> getAll() {

    Predicate<String> filter = Predicates.not(new RefPrefixPredicate(TRANSACTIONS_PREFIX));
    Map<String, String> allButTransactions = Maps.filterKeys(ImmutableMap.copyOf(this.refs), filter);
    return allButTransactions;
}