Example usage for com.google.common.collect ImmutableList contains

List of usage examples for com.google.common.collect ImmutableList contains

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:org.trnltk.apps.tokenizer.TextTokenizerDefaultTrainingApp.java

@App
public void dumpSmallTokenizationGraph_onlyForWordsAndDot_InDotFormat() {
    final TextTokenizerTrainer localTokenizer = new TextTokenizerTrainer(2, true);
    localTokenizer.train("ali veli.", "ali veli .");

    dumpTokenizationGraph(localTokenizer.build(), new Predicate<TokenizationGraphNode>() {
        @Override/*from w w  w. j  av a 2s .co m*/
        public boolean apply(TokenizationGraphNode input) {
            final ImmutableList<TextBlockType> types = input.getData().getTextBlockTypes();
            if (types.contains(TextBlockType.Abbreviation) || types.get(1).equals(TextBlockType.Sentence_Start))
                return false;
            return true;
        }
    },

            new Predicate<TokenizationGraphNode>() {
                @Override
                public boolean apply(TokenizationGraphNode input) {
                    final ImmutableList<TextBlockType> types = input.getData().getTextBlockTypes();
                    if (types.contains(TextBlockType.Abbreviation)
                            || types.get(0).equals(TextBlockType.Sentence_End)
                            || types.get(1).equals(TextBlockType.Dot))
                        return false;
                    return true;
                }
            },

            Predicates.<TokenizationGraphEdge>alwaysTrue());
}

From source file:ru.org.linux.user.UserTagService.java

/**
 * ?, ?      ?./*from   w w  w . j av  a 2s.co m*/
 *
 * @param user     ?
 * @param tagName  
 * @return true ?  ? ? 
 */
public boolean hasIgnoreTag(User user, String tagName) {
    ImmutableList<String> tags = ignoresGet(user);
    return tags.contains(tagName);
}

From source file:ru.org.linux.user.UserTagService.java

/**
 * ?, ?      ?.//from w w  w. j a v a 2  s  .c  om
 *
 * @param user     ?
 * @param tagName  
 * @return true ?  ? ? 
 */
public boolean hasFavoriteTag(User user, String tagName) {
    ImmutableList<String> tags = favoritesGet(user);
    return tags.contains(tagName);
}

From source file:org.eclipse.emf.ecore.xcore.ui.contentassist.XcoreProposalProvider.java

@Override
protected void lookupCrossReference(CrossReference crossReference, EReference reference,
        ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor,
        Predicate<IEObjectDescription> filter) {
    if (reference == XcorePackage.Literals.XREFERENCE__OPPOSITE) {
        XReference xReference = (XReference) contentAssistContext.getCurrentModel();
        final EStructuralFeature eReference = mapper.getMapping(xReference).getEStructuralFeature();
        final EClass eClass = eReference.getEContainingClass();
        final Predicate<IEObjectDescription> baseFilter = filter;
        filter = new Predicate<IEObjectDescription>() {
            public boolean apply(IEObjectDescription input) {
                // Filter out features that aren't of the correct type to be a valid opposite.
                //
                GenFeature genFeature = (GenFeature) input.getEObjectOrProxy();
                EStructuralFeature eStructuralFeature = genFeature.getEcoreFeature();
                return eStructuralFeature.getEType() == eClass && eStructuralFeature != eReference
                        && baseFilter.apply(input);
            }//from w w  w  .  j  ava 2 s. c o  m
        };
    } else if (reference == XcorePackage.Literals.XGENERIC_TYPE__TYPE) {
        EObject eObject = contentAssistContext.getCurrentModel();
        ImmutableList<AbstractElement> firstSetGrammarElements = contentAssistContext
                .getFirstSetGrammarElements();
        if (firstSetGrammarElements.contains(xcoreGrammarAccess.getXAttributeAccess().getTypeAssignment_3())
                || firstSetGrammarElements
                        .contains(xcoreGrammarAccess.getXAttributeAccess().getNameAssignment_5())
                || firstSetGrammarElements
                        .contains(xcoreGrammarAccess.getXGenericTypeAccess().getTypeAssignment_0())
                        && eObject instanceof XAttribute) {
            final Predicate<IEObjectDescription> baseFilter = filter;
            filter = new Predicate<IEObjectDescription>() {
                public boolean apply(IEObjectDescription input) {
                    // Filter out types that aren't data types.
                    //
                    EObject eObjectOrProxy = input.getEObjectOrProxy();
                    return (eObjectOrProxy instanceof GenDataType || eObjectOrProxy instanceof GenTypeParameter)
                            && baseFilter.apply(input);
                }
            };
        } else if (firstSetGrammarElements
                .contains(xcoreGrammarAccess.getXReferenceAccess().getTypeAssignment_4())
                || firstSetGrammarElements
                        .contains(xcoreGrammarAccess.getXGenericTypeAccess().getTypeAssignment_0())
                        && eObject instanceof XReference
                || firstSetGrammarElements
                        .contains(xcoreGrammarAccess.getXClassAccess().getSuperTypesAssignment_5_1())
                || firstSetGrammarElements
                        .contains(xcoreGrammarAccess.getXClassAccess().getSuperTypesAssignment_5_2_1())) {
            final Predicate<IEObjectDescription> baseFilter = filter;
            filter = new Predicate<IEObjectDescription>() {
                public boolean apply(IEObjectDescription input) {
                    // Filter out types that aren't classes.
                    //
                    EObject eObjectOrProxy = input.getEObjectOrProxy();
                    return (eObjectOrProxy instanceof GenClass || eObjectOrProxy instanceof GenTypeParameter)
                            && baseFilter.apply(input);
                }
            };
        }
    }
    super.lookupCrossReference(crossReference, reference, contentAssistContext, acceptor, filter);
}

From source file:com.spectralogic.ds3cli.command.GetDetailedObjects.java

private void checkFilterParams() throws BadArgumentException {
    // if filter-params are specified, ascertain that all are supported
    if (Guard.isMapNullOrEmpty(this.filterParams)) {
        return;/*w  w w  .j  a  v a 2  s  .c  om*/
    }
    final ImmutableList<String> legalParams = ImmutableList.of(CONTAINS, OWNER, NEWERTHAN, OLDERTHAN,
            LARGERTHAN, SMALLERTHAN, BEFORE, AFTER);
    for (final String paramName : this.filterParams.keySet()) {
        if (!legalParams.contains(paramName)) {
            throw new BadArgumentException("Unknown filter parameter: " + paramName);
        }
    }
}

From source file:com.google.template.soy.passes.StrictHtmlValidationPass.java

StrictHtmlValidationPass(ImmutableList<String> experimentalFeatures, ErrorReporter errorReporter) {
    this.enabledStrictHtml = experimentalFeatures.contains("stricthtml");
    this.errorReporter = errorReporter;
}

From source file:com.google.javascript.jscomp.RewriteGoogJsImports.java

@Nullable
private Node findGoogJsScriptNode(Node root) {
    ModulePath expectedGoogPath = null;/*from w ww.j  av  a  2  s .  co  m*/

    // Find Closure's base.js file. goog.js should be right next to it.
    for (Node script : root.children()) {
        ImmutableList<String> provides = compiler.getInput(script.getInputId()).getProvides();
        if (provides.contains(EXPECTED_BASE_PROVIDE)) {
            // Use resolveModuleAsPath as if it is not part of the input we don't want to report an
            // error.
            expectedGoogPath = compiler.getInput(script.getInputId()).getPath()
                    .resolveModuleAsPath("./goog.js");
            break;
        }
    }

    if (expectedGoogPath != null) {
        Node googScriptNode = null;

        for (Node script : root.children()) {
            if (compiler.getInput(script.getInputId()).getPath().equalsIgnoreLeadingSlash(expectedGoogPath)) {
                googScriptNode = script;
            } else if (script.getSourceFileName().endsWith("/goog.js")) {
                // Ban the name goog.js as input except for Closure's goog.js file. This simplifies a lot
                // of logic if the only file that is allowed to be named goog.js is Closure's.
                compiler.report(JSError.make(script.getSourceFileName(), -1, -1, CheckLevel.ERROR,
                        CANNOT_NAME_FILE_GOOG));
            }
        }

        return googScriptNode;
    }

    return null;
}

From source file:org.gradle.internal.component.external.model.DefaultIvyModuleResolveMetadata.java

private ImmutableList<ExcludeMetadata> filterExcludes(ImmutableList<String> hierarchy) {
    ImmutableList.Builder<ExcludeMetadata> filtered = ImmutableList.builder();
    for (Exclude exclude : excludes) {
        for (String config : exclude.getConfigurations()) {
            if (hierarchy.contains(config)) {
                filtered.add(exclude);// w  w  w.j a  v  a 2  s.c om
                break;
            }
        }
    }
    return filtered.build();
}

From source file:com.addthis.hydra.job.alert.JobAlertRunner.java

/**
 * Remove {@code jobId} from all alerts that are monitoring it. Delete alerts that are only monitoring this job.
 *//*from   w w  w .  j av  a 2  s. com*/
public void removeAlertsForJob(String jobId) {
    Set<String> alertIds = ImmutableSet.copyOf(jobToAlertsMap.get(jobId));
    for (String mappedAlertId : alertIds) {
        if (alertMap.computeIfPresent(mappedAlertId, (alertId, alert) -> {
            ImmutableList<String> jobIds = alert.jobIds;
            if (jobIds.contains(jobId)) {
                @Nullable
                AbstractJobAlert newAlert;
                if (jobIds.size() == 1) {
                    newAlert = null;
                } else {
                    newAlert = copyWithoutJobId(jobId, alert);
                }
                updateJobToAlertsMap(alertId, alert, newAlert);
                storeAlert(alertId, newAlert);
                return newAlert;
            } else {
                log.warn("jobToAlertsMap has mapping from job {} to alert {} but alert has no reference to job",
                        jobId, alertId);
                return alert;
            }
        }) == null) {
            log.warn("jobToAlertsMap has mapping from job {} to alert {} but alert does not exist", jobId,
                    mappedAlertId);
        }
    }
}

From source file:com.google.devtools.common.options.processor.OptionProcessor.java

/**
 * Check that the option lists at least one effect, and that no nonsensical combinations are
 * listed, such as having a known effect listed with UNKNOWN.
 *//* w  ww. j a  v a  2s. c  o m*/
private void checkEffectTagRationality(VariableElement optionField) throws OptionProcessorException {
    Option annotation = optionField.getAnnotation(Option.class);
    OptionEffectTag[] effectTags = annotation.effectTags();
    // Check that there is at least one OptionEffectTag listed.
    if (effectTags.length < 1) {
        throw new OptionProcessorException(optionField,
                "Option does not list at least one OptionEffectTag. If the option has no effect, "
                        + "please be explicit and add NO_OP. Otherwise, add a tag representing its effect.");
    } else if (effectTags.length > 1) {
        // If there are more than 1 tag, make sure that NO_OP and UNKNOWN is not one of them.
        // These don't make sense if other effects are listed.
        ImmutableList<OptionEffectTag> tags = ImmutableList.copyOf(effectTags);
        if (tags.contains(OptionEffectTag.UNKNOWN)) {
            throw new OptionProcessorException(optionField,
                    "Option includes UNKNOWN with other, known, effects. Please remove UNKNOWN from "
                            + "the list.");
        }
        if (tags.contains(OptionEffectTag.NO_OP)) {
            throw new OptionProcessorException(optionField,
                    "Option includes NO_OP with other effects. This doesn't make much sense. Please "
                            + "remove NO_OP or the actual effects from the list, whichever is correct.");
        }
    }
}