public static <T> List<T> unmodifiableList(List<T> list) {
        if (isUnmodifiableType(list.getClass())) {
            return list;
        }
        switch (list.size()) {
            case 0:
                return Collections.emptyList();
            case 1:
                return Collections.singletonList(list.get(0));
            default:
                return Collections.unmodifiableList(new ArrayList<>(list));
        }
    }
Return an unmodifiable copy of a list, or the same list if its already an unmodifiable type.

@param list the list
@param <T> element type
@return unmodifiable copy of a list, or the same list if its already an unmodifiable type
querydsl-core/src/main/java/com/querydsl/core/util/CollectionUtils.java