Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class LazyListManagerUtils {
public static <T> List<T> add(List<T> list, T item) {
if (list == null) {
list = new ArrayList<T>();
list.add(item);
}
else if (!list.contains(item)) {
list.add(item);
}
return list;
}
public static <T> List<T> remove(List<T> list, T item) {
if (list != null) {
list.remove(item);
if (list.isEmpty()) {
list = null;
}
}
return list;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.