OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Rev 174 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 149
Line 910... Line 910...
910
        final Map<K, V> res = createMap(key, val, key2, val2);
910
        final Map<K, V> res = createMap(key, val, key2, val2);
911
        res.put(key3, val3);
911
        res.put(key3, val3);
912
        return res;
912
        return res;
913
    }
913
    }
914
 
914
 
-
 
915
    @SafeVarargs
-
 
916
    public static <T> Map<T, T> createMapFromList(final T... keyAndVal) {
-
 
917
        return createMapFromList(Arrays.asList(keyAndVal));
-
 
918
    }
-
 
919
 
-
 
920
    public static <T> Map<T, T> createMapFromList(final List<T> keyAndVal) {
-
 
921
        final int size = keyAndVal.size();
-
 
922
        if (size % 2 != 0)
-
 
923
            throw new IllegalArgumentException(size + " is not an even number of values : " + keyAndVal);
-
 
924
        // arguments are ordered, so should the result
-
 
925
        final Map<T, T> res = new LinkedHashMap<>(size);
-
 
926
        for (int i = 0; i < size; i += 2) {
-
 
927
            res.put(keyAndVal.get(i), keyAndVal.get(i + 1));
-
 
928
        }
-
 
929
        return res;
-
 
930
    }
-
 
931
 
915
    /**
932
    /**
916
     * Creates a map with null values.
933
     * Creates a map with null values.
917
     * 
934
     * 
918
     * @param <K> type of key.
935
     * @param <K> type of key.
919
     * @param <V> type of value.
936
     * @param <V> type of value.