Created
September 13, 2013 18:30
-
-
Save dlew/6554307 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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