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:com.wmw.bank.BankValidator.java

public static <T extends Account> T validate(T account) {
    checkNotNull(account, "Account can't be null.");
    checkState(account.getAccountNumber() > 0, "Account number must be grater than 0.");
    checkState(account.getRoutingNumber() > 0, "Routing number must be grater than 0.");
    List<? extends Owner> owners = account.getOwners();
    checkNotNull(owners, "Owners can't be null.");
    checkState(!owners.isEmpty() && !owners.contains(null),
            "At least 1 owner required and every owner can't be null.");
    return account;
}

From source file:com.cognifide.cq.cqsm.core.scripts.ScriptFilters.java

public static Predicate filterByExecutionMode(final List<ExecutionMode> modes) {
    return new Predicate() {
        @Override/*from   www.  j  ava  2s .  co  m*/
        public boolean evaluate(Object o) {
            return modes.contains(((Script) o).getExecutionMode());
        }
    };
}

From source file:gov.nih.nci.iso21090.Tel.java

/**
 * @param scheme the scheme part of a URI.
 * @param allowedSchemes the schemes that we consider to be valid.
 * @return true if allowedSchemes is null or if it contains scheme.
 *//*from  ww  w .  j  av  a  2  s.co m*/
protected static boolean isAllowed(String scheme, List<String> allowedSchemes) {
    if (scheme == null) {
        return false;
    }
    return allowedSchemes == null || allowedSchemes.contains(scheme.toLowerCase(Locale.getDefault()));
}

From source file:com.github.pmerienne.cf.util.ListUtils.java

public static <T> List<T> randomSubList(List<T> items, int m) {
    List<T> res = new ArrayList<T>(m);
    int n = items.size();
    for (int i = n - m; i < n; i++) {
        int pos = RandomUtils.nextInt(i + 1);
        T item = items.get(pos);//from   w  w  w  . j  a  v  a  2  s .  c om
        if (res.contains(item))
            res.add(items.get(i));
        else
            res.add(item);
    }
    return res;
}

From source file:eu.morfeoproject.fast.catalogue.util.Util.java

/**
 * @return true iff the given param is defined in the request AND either no
 *          value is associated OR none of the values is equal to "n".
 *///from   ww w.j a v  a  2s  .c om
public static boolean yes(HttpServletRequest request, String param) {
    List<String> values = getParamValues(request, param);
    return values != null && !values.contains("n");
}

From source file:Main.java

public static <T> List<T> getLeftDiff(List<T> list1, List<T> list2) {
    if (isEmpty(list2)) {
        return list1;
    }//from  ww  w. j  a  va2s .c  o m
    List<T> list = new ArrayList<T>();
    if (isNotEmpty(list1)) {
        for (T o : list1) {
            if (!list2.contains(o)) {
                list.add(o);
            }
        }
    }
    return list;
}

From source file:com.ebay.jetstream.config.mongo.MongoScopesUtil.java

public static final boolean isLocalEligible(String changedBeanScope) {
    boolean eligible = false;
    try {/* w  ww .ja v a 2  s  .  c  o m*/
        List<String> servers = parseServerInfo(changedBeanScope);
        String localhostname = java.net.InetAddress.getLocalHost().getHostName();
        if (servers.contains(localhostname)) {
            eligible = true;
        } else {
            localhostname = java.net.InetAddress.getLocalHost().getCanonicalHostName();
            if (servers.contains(localhostname)) {
                eligible = true;
            }
        }
    } catch (Exception e) {
        LOGGER.info("isLocalEligible method ran into exception ", e);
    }

    return eligible;
}

From source file:nebula.plugin.metrics.model.Info.java

private static List<KeyValue> sanitizeKeyValues(List<KeyValue> keyValues, List<String> sanitizedProperties) {
    List<KeyValue> sanitizedKeyValues = new ArrayList<>();
    for (KeyValue keyValue : keyValues) {
        if (sanitizedProperties.contains(keyValue.getKey())) {
            sanitizedKeyValues.add(new KeyValue(keyValue.getKey(), "SANITIZED"));
        } else {//  www. java  2  s  . c o  m
            sanitizedKeyValues.add(keyValue);
        }
    }
    return sanitizedKeyValues;
}

From source file:biz.netcentric.cq.tools.actool.validators.Validators.java

public static boolean isValidAction(String action) {
    List<String> validActions = Arrays.asList(CqActions.ACTIONS);
    if (action == null) {
        return false;
    }/*  w w  w . j  av  a2 s  .  c  o  m*/

    if (!validActions.contains(action)) {
        return false;
    }

    return true;
}

From source file:hrider.io.FileHelper.java

public static void delete(File path, String... exclude) {
    List<String> excludedPaths = Arrays.asList(exclude);

    File[] files = path.listFiles();
    if (files != null) {
        for (File file : files) {
            if (!excludedPaths.contains(file.getName())) {
                if (file.isDirectory()) {
                    delete(file);/*from   w w  w .  j  a  v a  2 s.  c  o m*/
                }
                file.delete();
            }
        }
    }
}