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

/**
 * Merges the given two lists in a new list, but without duplicates.
 *//*from w  ww. j a  va  2s  .c  om*/
public static <T> List<T> mergeNoDuplicates(List<T> sourceList1, List<T> sourceList2) {
    List<T> ret = alist(sourceList1.size() + sourceList2.size());
    ret.addAll(sourceList1);
    for (T e : sourceList2) {
        if (false == ret.contains(e))
            ret.add(e);
    }
    return ret;
}

From source file:com.daphne.es.maintain.icon.web.controller.tmp.GenCssSql.java

private static void readClass() throws IOException {
    String fromFile = "C:\\Documents and Settings\\Administrator\\?\\a.txt";
    String toFile = "C:\\Documents and Settings\\Administrator\\?\\b.sql";
    String template = "insert into `maintain_icon` (`id`, `identity`, `css_class`, `type`) values(%1$d, '%2$s', '%2$s', 'css_class');;";

    List<String> cssClassList = FileUtils.readLines(new File(fromFile));
    List<String> hasReadList = Lists.newArrayList();
    FileWriter writer = new FileWriter(toFile);

    for (int i = 0, l = cssClassList.size(); i < l; i++) {
        if (!hasReadList.contains(cssClassList.get(i))) {
            writer.write(String.format(template, i + 1, cssClassList.get(i).trim()));
            writer.write("\r\n");
            hasReadList.add(cssClassList.get(i));
        }/*from w ww  .  j  a va  2 s .c  o  m*/
    }

    writer.close();
}

From source file:Main.java

public static void setFlashMode(Camera mCamera, Context item, int type) {
    Camera.Parameters params = mCamera.getParameters();
    List<String> FlashModes = params.getSupportedFlashModes();

    switch (type) {
    case 0://  w ww.j  a va2  s . co  m
        if (FlashModes.contains(Camera.Parameters.FLASH_MODE_AUTO))
            params.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
        else
            Toast.makeText(item, "Auto Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    case 1:
        if (FlashModes.contains(Camera.Parameters.FLASH_MODE_OFF))
            params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
        else
            Toast.makeText(item, "Off Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    case 2:
        if (FlashModes.contains(Camera.Parameters.FLASH_MODE_ON))
            params.setFlashMode(Camera.Parameters.FLASH_MODE_ON);
        else
            Toast.makeText(item, "On Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    case 3:
        if (FlashModes.contains(Camera.Parameters.FLASH_MODE_RED_EYE))
            params.setFlashMode(Camera.Parameters.FLASH_MODE_RED_EYE);
        else
            Toast.makeText(item, "Red Eye Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    case 4:
        if (FlashModes.contains(Camera.Parameters.FLASH_MODE_TORCH))
            params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
        else
            Toast.makeText(item, "Torch Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    }

    mCamera.setParameters(params);
}

From source file:com.epam.ta.reportportal.commons.Preconditions.java

/**
 * {@link UserConfig} should have one of input roles.
 * @param roles/*from w ww .ja va  2  s .  c  o m*/
 * @return
 */
public static Predicate<UserConfig> hasProjectRoles(final List<ProjectRole> roles) {
    return input -> roles.contains(input.getProjectRole());
}

From source file:Main.java

public static void deleteDuplicate(List<Integer> list) {
    List<Integer> tempList = new ArrayList<Integer>();

    Iterator<Integer> iter = list.iterator();
    while (iter.hasNext()) {
        Integer current = iter.next();
        if (tempList.contains(current)) {
            iter.remove();/*from ww w . java  2  s  . co m*/
        } else {
            tempList.add(current);
        }
    }
}

From source file:Main.java

public static final <T> boolean equalsIgnoreSequence(T[] array1, T[] array2) {
    if (array1 == null && array2 == null) {
        return true;
    } else if (array1 == null || array2 == null) {
        return false;
    }/*from  w ww.  j  a  v a  2  s.co m*/
    if (array1.length != array2.length) {
        return false;
    }
    List<T> list = Arrays.asList(array2);
    for (int i = 0; i < array1.length; i++) {
        T o1 = array1[i];
        if (!list.contains(o1)) {
            return false;
        }
    }
    return true;
}

From source file:apiPull.getItem.java

private static boolean rarityCheck(ItemInfo myItem) {
    boolean r = false;
    try {//  w  w w .java2s .  c  o  m
        List rValid = Arrays.asList(myItem.getRarity());
        r = rValid.contains(ItemRarity.EXOTIC);
    } catch (Exception ex) {
        System.out.println("Error; " + ex);
    }
    return r;
}

From source file:Main.java

private static <E> void addElements(boolean removeDuplicates, final List<E> result,
        Collection<? extends E> elements) {
    for (E item : elements) {
        if (removeDuplicates) {
            if (!result.contains(item)) {
                result.add(item);// ww w.ja va2s .c om
            }
        } else {
            result.add(item);
        }
    }
}

From source file:apiPull.getItem.java

private static boolean typeCheck(ItemInfo myItem) {
    boolean type = false;
    try {/*w w  w.j  av a 2 s. c  o  m*/
        List tValid = Arrays.asList(myItem.getType());
        type = (tValid.contains(ItemType.ARMOR) || (tValid.contains(ItemType.BACK)
                || (tValid.contains(ItemType.WEAPON) || (tValid.contains(ItemType.TRINKET)))));
    } catch (Exception ex) {
        System.out.println("Error; " + ex);
    }
    return type;
}

From source file:apiPull.getItem.java

private static boolean gameTypeCheck(ItemInfo myItem) {
    boolean gt = false;
    try {/*from www .  ja  v  a 2 s . c o m*/
        List gtValid = Arrays.asList(myItem.getGameTypes());
        gt = gtValid.contains(GameType.PVE);
    } catch (Exception ex) {
        System.out.println("Error; " + ex);
    }
    return gt;
}