Java Utililty Methods List Copy

List of utility methods to do List Copy

Description

The list of methods to do List Copy are organized into topic(s).

Method

ListcopyList(List list)
copy List
if (list == null)
    return Collections.emptyList();
List<String> result = new ArrayList<String>(list.size());
result.addAll(list);
return Collections.unmodifiableList(result);
ListcopyList(List list)
copy List
return new ArrayList<T>(list);
ListcopyList(List list)
copy List
if (list == null || list.size() == 0) {
    return Collections.emptyList();
for (int i = list.size() - 1; i >= 0; i--) {
    assert list.get(i) != null;
return Collections.unmodifiableList(new ArrayList<>(list));
ListcopyList(List list)
copy List
Iterator<T> it = list.iterator();
LinkedList<T> newList = new LinkedList<T>();
while (it.hasNext()) {
    newList.add(it.next());
return newList;
ListcopyList(List master, List slave)
Copia il contenuto della prima lista (master) nella seconda (slave).
slave.clear();
slave.addAll(slave);
return slave;
ListcopyList(List original)
copy List
List<T> copy = null;
if (original != null) {
    copy = new ArrayList<T>();
    if (!original.isEmpty()) {
        copy.addAll(original);
return copy;
...
ListcopyList(Object object)
copy List
if (!(object instanceof List)) {
    return new ArrayList<>();
List<?> list = (List<?>) object;
List<String> temp = new ArrayList<>();
for (Object ob : list) {
    if (ob instanceof String) {
        temp.add((String) ob);
...
ListcopyListOnlySpecified(List list, int[] indexes)
copy List Only Specified
List<T> newlist = new ArrayList<T>();
for (int i = 0; i < list.size(); i++) {
    if (Arrays.asList(indexes).contains(i)) {
        newlist.add(list.get(i));
return newlist;
ListcopyListRaw(List master, List slave)
Copia il contenuto della prima lista (master) nella seconda (slave), uno ad uno in modo che vengano eseguiti gli eventuali cast impliciti.
slave.clear();
for (Object dto : master) {
    slave.add(dto);
return slave;
ListcopyNullable(List original)
copy Nullable
if (original == null) {
    return null;
return new ArrayList<>(original);