public static <K,V> Map<K,V> put(Map<K,V> map, K key, V value) {
        final int size = map.size();
        if (size == 0) {
            return Collections.singletonMap(key, value);
        } else if (isUnmodifiableType(map.getClass())) {
            map = new HashMap<>(map);
        }
        map.put(key, value);
        return map;
    }
Return an unmodifiable copy of a set, or the same set if its already an unmodifiable type.

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