@SuppressWarnings("unchecked")
    public static <K, V> Map<V, K> flip(Map<K, V> map) {
        if (isEmptyMap(map)) {
            return (Map<V, K>) map;
        }
        Set<V> set = new HashSet<>(map.values());
        if (set.size() != map.size()) {
            throw new IllegalArgumentException("The map value must be unique.");
        }
        return map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
    }
@Test
    void testFlip() {
        assertEquals(CollectionUtils.flip(null), null);
        Map<String, String> input1 = new HashMap<>();
        input1.put("k1", null);
        input1.put("k2", "v2");
        Map<String, String> output1 = new HashMap<>();
        output1.put(null, "k1");
        output1.put("v2", "k2");
        assertEquals(CollectionUtils.flip(input1), output1);
        Map<String, String> input2 = new HashMap<>();
        input2.put("k1", null);
        input2.put("k2", null);
        assertThrows(IllegalArgumentException.class, () -> CollectionUtils.flip(input2));
    }