Java Set to List setToList(Set set)

Here you can find the source of setToList(Set set)

Description

set To List

License

Apache License

Declaration

public static <T> List<T> setToList(Set<T> set) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {

    public static <T> List<T> setToList(Set<T> set) {
        if (isNotEmpty(set)) {
            List<T> list = new ArrayList<>();
            for (T t : set) {
                list.add(t);/*w w w.  j a  va2  s. c o  m*/
            }
            return list;
        }
        return Collections.emptyList();
    }

    public static boolean isNotEmpty(Collection<? extends Object> col) {
        return col != null && col.size() > 0;
    }

    public static boolean isNotEmpty(Map<? extends Object, ? extends Object> map) {
        return map != null && map.size() > 0;
    }
}

Related

  1. setToList(Set set)
  2. setToList(Set set)
  3. setToList(Set set)
  4. setToList(Set set)
  5. setToList(Set set)
  6. toList(Set s)
  7. toList(Set set)
  8. toList(Set theValues)