Beispiel #1
0
 @SuppressWarnings("unchecked")
 public static <T> T toCollection(Class<T> clz, Object value) {
   if (Typ.isList(clz)) {
     return (T) toList(value);
   } else if (Typ.isSortedSet(clz)) {
     return (T) toSortedSet(value);
   } else if (Typ.isSet(clz)) {
     return (T) toSet(value);
   } else {
     return (T) toList(value);
   }
 }
Beispiel #2
0
  public static Collection<Object> createCollection(Class<?> type, int size) {

    if (type == List.class) {
      return new ArrayList<>(size);
    } else if (type == SortedSet.class) {
      return new TreeSet<>();
    } else if (type == Set.class) {
      return new LinkedHashSet<>(size);
    } else if (Typ.isList(type)) {
      return new ArrayList<>();
    } else if (Typ.isSortedSet(type)) {
      return new TreeSet<>();
    } else if (Typ.isSet(type)) {
      return new LinkedHashSet<>(size);
    } else {
      return new ArrayList(size);
    }
  }