Methods Summary |
---|
public static boolean | listContains(java.util.List list, T needle)Return {@code} true if the {@code list} contains the {@code needle}.
if (list == null) {
return false;
} else {
return list.contains(needle);
}
|
public static boolean | listElementsEqualTo(java.util.List list, T single)Return {@code true} if the {@code list} is only a single element equal to
{@code single}.
if (list == null) {
return false;
}
return (list.size() == 1 && list.contains(single));
|
public static T | listSelectFirstFrom(java.util.List list, T[] choices)Return the first item from {@code choices} that is contained in the {@code list}.
Choices with an index closer to 0 get higher priority. If none of the {@code choices}
are in the {@code list}, then {@code null} is returned.
if (list == null) {
return null;
}
for (T choice : choices) {
if (list.contains(choice)) {
return choice;
}
}
return null;
|
public static java.lang.String | listToString(java.util.List list)Return a human-readable representation of a list (non-recursively).
if (list == null) {
return null;
}
StringBuilder sb = new StringBuilder();
sb.append('[");
int size = list.size();
int i = 0;
for (T elem : list) {
sb.append(elem);
if (i != size - 1) {
sb.append(',");
}
i++;
}
sb.append(']");
return sb.toString();
|