List of usage examples for java.util List contains
boolean contains(Object o);
From source file:Main.java
/** * Determines if a given full qualified class name matches any import style patterns. */// ww w . j a v a 2s. com public static boolean isMatched(Map<String, Object> patterns, String className) { // Array [] object class names are "[x", where x is the first letter of the array type // -> NO '.' in class name, thus! // see http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29 String qualifiedNamespace = className; String name = className; if (className.indexOf('.') > 0) { qualifiedNamespace = className.substring(0, className.lastIndexOf('.')).trim(); name = className.substring(className.lastIndexOf('.') + 1).trim(); } else if (className.indexOf('[') == 0) { qualifiedNamespace = className.substring(0, className.lastIndexOf('[')); } Object object = patterns.get(qualifiedNamespace); if (object == null) { return true; } else if (STAR.equals(object)) { return false; } else if (patterns.containsKey("*")) { // for now we assume if the name space is * then we have a catchall *.* pattern return true; } else { List list = (List) object; return !list.contains(name); } }
From source file:Main.java
public static List<Object> removeDuplicateList(List<Object> list) { List<Object> tempList = new ArrayList<Object>(); for (Object obj : list) { if (!tempList.contains(obj)) { tempList.add(obj);/*from ww w. ja va 2 s .c om*/ } } return tempList; }
From source file:Main.java
/** * Checks whether the given placeholder is encrypted. * //from ww w .jav a 2 s.c o m * @param placeholder : to check. * @param encryptedPlaceholder : list of all encrypted placeholder. * @return true if it is */ public static boolean isEncryptedPlaceholder(String placeholder, List<String> encryptedPlaceholder) { if (encryptedPlaceholder != null) { return encryptedPlaceholder.contains(placeholder); } return false; }
From source file:Main.java
/** * Adds the content of the second list to the first list, but checks for each element if the element is not already there. * To be used as a Set replacement, if the order of inserts is relevant. * @param <T>/*from w ww .jav a 2 s .c o m*/ * @param l1 * @param l2 * @return */ public static <T> List<T> addAllUnique(List<T> l1, List<T> l2) { for (T element : l2) { if (!l1.contains(element)) { l1.add(element); } } return l1; }
From source file:Main.java
public static <T> boolean containsAny(List<? extends T> c1, List<? extends T> c2) { for (int i = 0; i < c2.size(); i++) { if (c1.contains(c2.get(i))) { return true; }//from w w w . j a va2 s. c o m } return false; }
From source file:Main.java
public static List<String> removeDuplicates(List<String> oldList) { List<String> newList = new ArrayList<String>(); for (String entry : oldList) { if (!newList.contains(entry)) { newList.add(entry);//from www. j av a 2s .c o m } } return newList; }
From source file:Main.java
public static <T> List<T> removeRepeat(List<T> list) { if (isEmpty(list)) return list; List<T> result = new ArrayList<T>(); for (T e : list) { if (!result.contains(e)) { result.add(e);/* w w w . ja v a 2s.c o m*/ } } return result; }
From source file:Main.java
public static <T> List<T> removeRepeat(List<T> list) { if (isEmpty(list)) { return list; }// w w w .j a v a 2 s. c o m List<T> result = new ArrayList<T>(); for (T e : list) { if (!result.contains(e)) { result.add(e); } } return result; }
From source file:Main.java
public static <T> List<T> intersection(List<T> list1, List<T> list2) { List<T> list = new ArrayList<T>(); for (T t : list1) { if (list2.contains(t)) { list.add(t);// www . j a v a 2 s . com } } return list; }
From source file:Main.java
public static String[] arrayUnique(String[] a) { // array_unique List<String> list = new LinkedList<String>(); for (int i = 0; i < a.length; i++) { if (!list.contains(a[i])) { list.add(a[i]);/*from w w w . ja v a2 s . c o m*/ } } return (String[]) list.toArray(new String[list.size()]); }