List of usage examples for java.util List contains
boolean contains(Object o);
From source file:Main.java
public static String[] array_unique(String[] strs) { // array_unique List<String> list = new LinkedList<String>(); for (int i = 0; i < strs.length; i++) { if (!list.contains(strs[i])) { list.add(strs[i]);/* w w w. j a va 2s . c o m*/ } } return (String[]) list.toArray(new String[list.size()]); }
From source file:Main.java
public static <Key> void removeFromMapThatKeyNotExistInList(Map<Key, ?> map, List<Key> list) { Object[] keys = map.keySet().toArray(); for (Object key : keys) { if (!list.contains(key)) { map.remove(key);/* ww w. j a v a2 s . com*/ } } }
From source file:Main.java
@Nullable private static String removePunctuation(@Nullable String pWord) { if (pWord == null || pWord.isEmpty()) return pWord; String mResult = pWord;/*from w w w .j av a 2 s .co m*/ String[] mPunctuation = new String[] { ".", ",", ";", ":", "?", "!", "(", ")" }; List<String> mPunctuationList = Arrays.asList(mPunctuation); while (mResult.length() > 0 && mPunctuationList.contains(mResult.substring(mResult.length() - 1))) { mResult = mResult.substring(0, mResult.length() - 1); } while (mResult.length() > 0 && mPunctuationList.contains(mResult.substring(0, 1))) { mResult = mResult.substring(1, mResult.length()); } return mResult; }
From source file:Main.java
static boolean isFlashModeSupported(@NonNull String flashMode, @NonNull Camera camera) { List<String> supportedFlashModes = camera.getParameters().getSupportedFlashModes(); return supportedFlashModes != null && supportedFlashModes.contains(flashMode); }
From source file:Main.java
public static <T> Object getContent(List<T> collection, Object object) { Object retValue = null;/*from www . j av a 2 s . c om*/ if (collection != null && !collection.isEmpty() && collection.contains(object)) { retValue = collection.get(collection.indexOf(object)); } return retValue; }
From source file:com.amazon.utils.ListUtils.java
/** * Add the item to the list if the item is not already in the list. * * @param list List.//from ww w . j a va 2 s .co m * @param item Item to add to the list. * @param <T> Item type. * @return True if the item was added, false otherwise. */ public static <T> boolean safeAdd(List<T> list, T item) { if (list.contains(item)) { return false; } return list.add(item); }
From source file:net.landora.video.filestate.DirectoryUUIDChecker.java
public static boolean validateUUID(File directory, String uuid) { try {//from www. j a va2 s.c o m File uuidFile = new File(directory, UUID_FILE); if (!uuidFile.exists()) { return false; } List<String> lines = FileUtils.readLines(uuidFile); return lines.contains(uuid); } catch (Exception e) { log.error("Error checking for directory uuid: " + directory, e); return false; } }
From source file:Main.java
public static List<Long> crossing(List<Long> list1, List<Long> list2) { List<Long> resultList = new ArrayList(); for (Long l : list1) { if (list2.contains(l)) { resultList.add(l);//from w w w .j a v a2 s. c om } } return resultList; }
From source file:Main.java
public static <T> boolean isSubset(List<T> subList, List<T> list) { if (subList == null || list == null || subList.isEmpty() || list.isEmpty()) { return false; }//ww w . j a va2 s.c o m List<T> subList1 = new ArrayList(); subList1.addAll(subList); for (T t : list) { if (subList1.contains(t)) { subList1.remove(t); } } if (subList1.isEmpty()) { return true; } return false; }
From source file:com.aliyun.openservices.odps.console.commands.HtmlModeCommand.java
/** * ??command/*from w ww . j a v a 2 s . c o m*/ * **/ public static HtmlModeCommand parse(List<String> optionList, ExecutionContext sessionContext) { if (optionList.contains("--html")) { optionList.remove(optionList.indexOf("--html")); return new HtmlModeCommand("--html", sessionContext); } return null; }