Example usage for java.util List contains

List of usage examples for java.util List contains

Introduction

In this page you can find the example usage for java.util List contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:nl.surfnet.coin.selfservice.interceptor.AuthorityScopeInterceptor.java

protected static boolean containsRole(List<Authority> authorities, Authority... authority) {
    for (Authority auth : authority) {
        if (authorities.contains(auth)) {
            return true;
        }//from ww w . ja  v a2  s  .c om
    }
    return false;
}

From source file:org.elasticsearch.test.rest.yaml.ClientYamlTestClient.java

private static boolean sendBodyAsSourceParam(List<String> supportedMethods, String contentType) {
    if (supportedMethods.contains(HttpGet.METHOD_NAME)) {
        if (contentType.startsWith(ContentType.APPLICATION_JSON.getMimeType())
                || contentType.startsWith(YAML_CONTENT_TYPE.getMimeType())) {
            return RandomizedTest.rarely();
        }/*w  w w . j ava 2 s .c o m*/
    }
    return false;
}

From source file:Main.java

/**
 * Returns whether a node is actionable. That is, the node supports one of
 * {@link AccessibilityNodeInfoCompat#isClickable()},
 * {@link AccessibilityNodeInfoCompat#isFocusable()}, or
 * {@link AccessibilityNodeInfoCompat#isLongClickable()}.
 *
 * @param node The {@link AccessibilityNodeInfoCompat} to evaluate
 * @return {@code true} if node is actionable.
 *///  w  w  w  . j ava2 s.co  m
public static boolean isActionableForAccessibility(@Nullable AccessibilityNodeInfoCompat node) {
    if (node == null) {
        return false;
    }

    if (node.isClickable() || node.isLongClickable() || node.isFocusable()) {
        return true;
    }

    List actionList = node.getActionList();
    return actionList.contains(AccessibilityNodeInfoCompat.ACTION_CLICK)
            || actionList.contains(AccessibilityNodeInfoCompat.ACTION_LONG_CLICK)
            || actionList.contains(AccessibilityNodeInfoCompat.ACTION_FOCUS);
}

From source file:Main.java

/**
 * Get the interfaces for the specified class.
 *
 * @param cls  the class to look up, may be <code>null</code>
 * @param interfacesFound the <code>Set</code> of interfaces for the class
 *//*from w ww.  j ava 2 s.c om*/
private static void getAllInterfaces(Class cls, List interfacesFound) {
    while (cls != null) {
        Class[] interfaces = cls.getInterfaces();

        for (int i = 0; i < interfaces.length; i++) {
            if (!interfacesFound.contains(interfaces[i])) {
                interfacesFound.add(interfaces[i]);
                getAllInterfaces(interfaces[i], interfacesFound);
            }
        }

        cls = cls.getSuperclass();
    }
}

From source file:Main.java

public static List<String> evalXPathAsStringList(Object item, String xpath, XPathFactory factory,
        boolean includeDuplicates) throws XPathExpressionException {
    NodeList nl = evalXPathAsNodeList(item, xpath, factory);

    List<String> result = new ArrayList<String>(nl.getLength());

    for (int i = 0; i < nl.getLength(); i++) {
        String text = nl.item(i).getTextContent();
        if (includeDuplicates || !result.contains(text)) {
            result.add(text);/*  w ww  . j a  v  a  2 s. c  om*/
        }
    }

    return result;
}

From source file:br.ufpr.inf.gres.utils.TestCaseUtils.java

/**
 * Get the test cases selected indexes in relation the test case set
 *
 * @param testCasesSelected The test cases that I want discovery the indexes
 * @param testCases The test cases set// ww  w.j  av  a2 s  .  c  o m
 * @return
 * @throws TestCaseSetSelectionException
 */
public static List<Integer> getVariables(List<String> testCasesSelected, List<TestCase> testCases)
        throws TestCaseSetSelectionException {

    return Arrays.asList(ArrayUtils.toObject(IntStream.range(0, testCases.size())
            .filter(i -> testCasesSelected.contains(testCases.get(i).getDescription())).toArray()));
}

From source file:Main.java

public static List intersection(List list1, List list2) {
    List result = new ArrayList(list1.size() + list2.size());
    Object item;//from   w  w w . ja va 2  s . c o m
    for (int i = 0, max_i = list1.size(); i < max_i; i++) {
        item = list1.get(i);
        if (list2.contains(item)) {
            result.add(item);
        }
    }

    return result;
}

From source file:com.pseudosudostudios.jdd.utils.ScoreSaves.java

/**
 * Appends a new game @param e the new game to be added
 *//*www .  j  a v a2 s.c  o m*/
public static void addNewScore(Context c, Entry e) {
    List<Entry> es = getSaves(c);
    for (Entry ez : es)
        if (ez.equals(e))
            return;
    if (!es.contains(e))
        es.add(e);
    writeFile(c, es);
}

From source file:grails.util.GrailsConfig.java

/**
 * Configuration Value lookup with a default value and a list of allowed values.
 *
 * @param key           the flattened key
 * @param defaultValue  the default value
 * @param allowedValues List of allowed values
 * @param <T>           the type parameter
 * @return the value retrieved by ConfigurationHolder.flatConfig, if it is contained in <code>allowedValues</code>, otherwise the <code>defaultValue</code>
 *///from   w w w  .  j  a v  a2  s.  co m
public static <T> T get(String key, T defaultValue, List<T> allowedValues) {
    T v = get(key, defaultValue);
    if (!allowedValues.contains(v)) {
        LOG.warn(String.format("Configuration value for key %s is not one of the allowed values (%s)", key,
                DefaultGroovyMethods.inspect(allowedValues)));
        return defaultValue;
    }
    return v;
}

From source file:Main.java

public static void collectXpathContainText(Node node, String textContent, List<String> holder) {
    if (textContent.equals(node.getTextContent())) {
        String xpath = getXPath(node);
        if (!holder.contains(xpath)) {
            holder.add(xpath);/*  w w  w. j a  va 2  s  .  c  o  m*/
        }
    }

    if (node.hasChildNodes()) {
        Node child = node.getFirstChild();
        while (child != null) {
            collectXpathContainText(child, textContent, holder);
            child = child.getNextSibling();
        }
    }
}