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:Main.java

public static void chooseWhiteBalance(Camera.Parameters parameters, String whiteBalance) {
    List<String> supportedWhiteBalance = parameters.getSupportedWhiteBalance();

    if (supportedWhiteBalance != null) {
        if (supportedWhiteBalance.contains(whiteBalance)) {
            parameters.setWhiteBalance(whiteBalance);
        }/*from w  w  w  .  ja v a  2 s  .  c o m*/
    }
}

From source file:Main.java

public static List<String> getDiffentElement(List<String> minList, List<String> maxList) {
    List<String> newList = new ArrayList<String>();
    for (String max : maxList) {
        if (!(minList.contains(max))) {
            newList.add(max);/* www .java  2  s .  com*/
        }
    }
    return newList;
}

From source file:Main.java

public static long contains(List list) {
    long start, stop, result = 0;
    for (int i = 0; i < 100; i++) {
        start = System.nanoTime();
        list.contains(list.size() - i);
        stop = System.nanoTime();
        result += stop - start;//from  w w w .j  a v a  2  s .  c  om
    }
    return result / 100;
}

From source file:Main.java

public static boolean containsAny(List<?> value, Object[] values) {
    if (value != null && values != null) {
        for (Object v : values) {
            if (value.contains(v)) {
                return true;
            }/*w  w  w .  ja  v  a2s. co m*/
        }
    }
    return false;
}

From source file:de.jfachwert.bank.BIC.java

/**
 * Hierueber kann man eine BIC ohne den Umweg ueber den Konstruktor
 * validieren./*www .j  ava 2 s .com*/
 *
 * @param bic die BIC (11- oder 14-stellig)
 * @return die validierte BIC (zur Weiterverarbeitung)
 */
public static String validate(String bic) {
    String normalized = StringUtils.trim(bic);
    List<Integer> allowedLengths = Arrays.asList(8, 11, 14);
    if (!allowedLengths.contains(normalized.length())) {
        throw new InvalidLengthException(normalized, allowedLengths);
    }
    return normalized;
}

From source file:Main.java

/**
 * Removes all duplicates from the given {@link Collection}. What is / isn't
 * a duplicate is determined by the method used by a {@link ArrayList}'s
 * {@link List#contains(Object)} implementation.
 *
 * @param collection the {@link Collection} to remove duplicates from
 * @param <T> the type of the input {@link Collection}
 * @return the given {@link Collection}, without duplicates
 *//*  w  ww  .  ja  va 2 s .  c  om*/
public static <T extends Collection<?>> T trimDuplicates(T collection) {
    List<Object> noDuplicates = new ArrayList<>(collection.size());
    collection.forEach((object) -> {
        if (noDuplicates.contains(object)) {
            collection.remove(object);
        } else {
            noDuplicates.add(object);
        }
    });
    return collection;
}

From source file:edu.duke.cabig.c3pr.utils.web.C3PRWebUtils.java

public static boolean containsConsentingMethod(List list, String consentMethod) {
    ConsentingMethod consentingMethod = ConsentingMethod.getByCode(consentMethod);
    return list.contains(consentingMethod);
}

From source file:Main.java

/**
 * Safety delete element included in source collection from target collection
 *
 * @param src    source collection/*  ww w .ja v a  2 s.  co  m*/
 * @param target target collection
 */
public static void safetyDeleteCollection(List src, List target) {
    int srcSize = src.size();
    for (int i = 0; i < srcSize; i++) {
        Object data2Deleted = src.get(i);
        if (target.contains(data2Deleted)) {
            target.remove(data2Deleted);
            srcSize--;
        }
    }
}

From source file:Main.java

@Deprecated
public static void filterList(List<Map<String, Object>> list, String key) {

    List<Object> keys = new ArrayList<>();
    for (Map<String, Object> map : list) {

        Object object = map.get(key);

        if (!keys.contains(object)) {

            keys.add(object);/*from   w  w w.ja v  a2 s  . c  om*/
        } else {

            list.remove(map);
        }
    }
}

From source file:Main.java

/**
 * Checks if string representation corresponds to the collection. Parts of an expected collection should not contain
 * delimiter./*from   w  ww.  java  2 s .co m*/
 */
public static boolean isStringPermutationOfCollection(String input, Collection<String> expected,
        String delimeter, int trimFromStart, int trimFromEnd) {
    input = input.substring(trimFromStart, input.length() - trimFromEnd);
    List<String> parts = new ArrayList<>(Arrays.asList(input.split(Pattern.quote(delimeter))));
    for (String part : expected) {
        if (parts.contains(part)) {
            parts.remove(part);
        }
    }
    return parts.isEmpty();
}