List of usage examples for java.util List indexOf
int indexOf(Object o);
From source file:Main.java
public static <T> int indexOf(List<? extends T> source, T t) { return source.indexOf(t); }
From source file:Main.java
public static boolean isSupported(String value, List<String> supported) { return supported != null && supported.indexOf(value) >= 0; }
From source file:Main.java
public static <T> int indexOf(List<? extends T> source, Object o) { return source.indexOf(o); }
From source file:Main.java
public static String seek(List<String> strings1, List<String> strings2, String content) { int idx = strings1.indexOf(content); if (idx == -1) return null; return strings2.get(idx); }
From source file:Main.java
/** * @param string - this is the current value, e.g. itemNo * @param list - list of strings, e.g. list of products * @return string value//from w w w . jav a 2 s.c om * method = getNextInList * Send in value and a list of values, returns the next value from the list. * returns null if the value sent in is the last value in the list. * */ public static String getNextInList(String string, List list) { String nextString = null; int i = list.indexOf(string); int size = list.size() - 1; if (i == size) {//this is the last item/value in the list System.out.println("this is the last item/value in the list"); return nextString; } else { nextString = list.get(i + 1).toString(); System.out.println("what is next item/value= " + nextString); } return nextString; }
From source file:Main.java
public static <T> T getNext(final List<T> items, T item) { int index = items.indexOf(item); if (index >= 0) { int nextIndex = (index + 1) % items.size(); return items.get(nextIndex); }/*from www .j av a 2s . c o m*/ return null; }
From source file:Main.java
/** * @param string - this is the current value, e.g. itemNo * @param list - list of strings, e.g. list of products * @return string value/*from w w w. j av a2 s. co m*/ * method = getPreviousInList * Send in value and a list of values, returns the previous value from the list. * returns null if the value sent in is the first value in the list. * */ public static String getPreviousInList(String string, List list) { String previousString = null; int i = list.indexOf(string); if (i == 0) {//this is the first value in the list System.out.println("this is the first item/string value in the list"); return previousString; } else { previousString = list.get(i - 1).toString(); System.out.println("what is previous item/string value= " + previousString); } return previousString; }
From source file:Main.java
public static boolean cameraHasColorEffect(Camera c, String colorEffect) { List<String> listOfColorEffects = c.getParameters().getSupportedColorEffects(); if (listOfColorEffects.indexOf(colorEffect) != -1) { return true; }// w w w .ja va 2s. co m return false; }
From source file:Main.java
public static <T> List<T> popFirstSubList(List<T> originList, T fromObj, T toObj) { int fromIndex = originList.indexOf(fromObj); if (fromIndex == -1) { return null; }//from w ww . j av a 2 s .c o m int toIndex = originList.indexOf(toObj) + 1; if (toIndex == 0) { return null; } return popSubList(originList, fromIndex, toIndex); }
From source file:Main.java
/** * @param string - this is the current value, e.g. itemNo * @param list - list of strings, e.g. list of products * @return string value/*from w ww .ja va2 s . c o m*/ * method = getNextInList * Send in value and a list of values, returns the next value from the list. * returns null if the value sent in is the last value in the list. * */ public static String getNextInList(String string, List list) { String nextString = null; if (list != null) { int i = list.indexOf(string); if (list == null || i == list.size() - 1 || list.size() < 2) {//this is the last item/value in the list System.out.println("this is the last item/value in the list"); return nextString; } else { nextString = list.get(i + 1).toString(); System.out.println("what is next item/value= " + nextString); } } return nextString; }