コレクションを配列に変換する。
@param collection 変換対象のコレクション。
@return 変換した配列。
@throws NullPointerException collection is null.
435693
public static int[] toArray(final Collection<Integer> collection) {
        Objects.requireNonNull(collection);
        
        final int size = collection.size();
        final int[] array = new int[size];
        
        int i=0;
        for(Integer value : collection) {
            array[i] = value;
            i++;
        }
        
        return array;
    }
840084
public static <T> Collection<T> addAllNotNull(Collection<T> to, Collection<? extends T> what) {
        Collection<T> data = safeCollection(to);
        if (!isEmpty(what)) {
            for (T t : what) {
                if (t != null) {
                    data.add(t);
                }
            }
        }
        return data;
    }
1163166
public static <T> List<T> list(boolean isLinked, Collection<T> collection) {
		if (null == collection) {
			return list(isLinked);
		}
		return isLinked ? new LinkedList<T>(collection) : new ArrayList<T>(collection);
	}
1117853
private boolean isShardedCollection(DBCollection collection) {

        DB config = collection.getDB().getMongo().getDB("config");
        DBCollection configCollections = config.getCollection("collections");

        DBObject dbObject = configCollections.findOne(new BasicDBObject(MONGO_DEFAULT_ID, collection.getFullName()));
        return dbObject != null;
    }
411520
@SuppressWarnings({ "rawtypes", "unchecked" })
    protected Object parseCollection(GetterMethodCover method, 
            Collection collection) {
        if(method.isArrayObjectCollection()) {
            return parseArrayObjectCollection(method, collection);
        }
        else if(method.isObjectCollection()) {
            return parseObjectCollection(method, collection);
        }
        else if(method.isByteCollection()) {
            return collectionToPrimitiveByteArray(collection);
        }
        else if(method.isCharCollection()) {
            return charCollectionToPrimitiveByteArray(collection);
        }
        else if(method.isArrayCollection()) {
            return parseArrayCollection(method, collection);
        }
        return collection;
    }
1264303
public static int[] toArray(final Collection<Integer> collection) {
        ArgUtils.notNull(collection, "collection");

        final int size = collection.size();
        final int[] array = new int[size];

        int i=0;
        for(Integer value : collection) {
            array[i] = value;
            i++;
        }

        return array;
    }
540653
@Override
	public <E> String serializeCollection(Collection<E> collection, Class<E> objectClazz) {
		if (collection == null)
			return null;

		SegmentedStringWriter source = new SegmentedStringWriter(buffer.get());
		try (SerializerWrapper serializer = createSerializer(source)) {
			mapperFor(objectClazz).serializeCollection(this, serializer, collection);
		} catch (Exception e) {
			e.printStackTrace();
			throw new KriptonRuntimeException(e);
		}
		return source.getAndClear();
	}
582909
public static <T> T getLast(Collection<T> collection) {
		if (isEmpty(collection)) {
			return null;
		}

		// 当类型List时，直接取得最后一个元素.
		if (collection instanceof List) {
			List<T> list = (List<T>) collection;
			return list.get(list.size() - 1);
		}

		return Iterators.getLast(collection.iterator());
	}
1114593
@Nullable
	private static CollectionJsonTemplate findTemplate(RepresentationModel<?> resource) {

		if (!resource.hasLink(IanaLinkRelations.SELF)) {
			return null;
		}

		return resource.getRequiredLink(IanaLinkRelations.SELF).getAffordances() //
				.stream() //
				.map(it -> it.getAffordanceModel(MediaTypes.COLLECTION_JSON)) //
				.map(CollectionJsonAffordanceModel.class::cast) //
				.filter(it -> !it.hasHttpMethod(HttpMethod.GET)) //
				.map(it -> new CollectionJsonTemplate().withData(it.getInputProperties())) //
				.findFirst().orElse(null);
	}
918540
private Object search(Collection<?> collection, String hashKey) {
    int hash = Integer.valueOf(hashKey);

    for (Object o : collection) {
      if (o.hashCode() == hash)
        return o;
    }

    //nothing found
    return null;
  }
552501
private void fillCollection(Collection<?> collection) {

        int count = 0;

        // 展开  Collection 容器, 输出逗号分隔以支持 IN (...) 语法
        // "IN :varlist" --> "IN (?, ?, ...)"
        if (collection.isEmpty()) {

            // 输出  "IN (NULL)" 保证不会产生错误
            builder.append(NULL);

        } else {

            // 输出逗号分隔的参数表
            for (Object value : collection) {

                if (value != null) {

                    if (count > 0) {
                        builder.append(COMMA);
                    }

                    // 输出参数内容
                    addArg(value);

                    builder.append(QUESTION);

                    count++;
                }
            }
        }
    }
534139
@SuppressWarnings("unchecked")
    @NonNull
    public static Set<String> nonNullSet(@Nullable Collection<String> collection) {
        return collection == null || collection.isEmpty()
                ? Collections.<String>emptySet()
                : new HashSet<String>(collection);
    }
164464
@SuppressWarnings({"rawtypes", "unchecked"})
    public static Collection convertListToCollection(final List list, final Class<Collection> toClass,
            final BeanFactory<Class<?>, Object> beanFactory) {

        if(list.getClass().equals(toClass)) {
            return list;
        }

        if(toClass.isInterface()) {
            if(List.class.isAssignableFrom(toClass)) {
                // 変換先がListの実態の場合はそのまま。
                return list;

            } else if(Set.class.isAssignableFrom(toClass)) {

                Collection value = (Collection) beanFactory.create(LinkedHashSet.class);
                value.addAll(list);
                return value;

            } else if(Queue.class.isAssignableFrom(toClass)) {

                Collection value = (Collection) beanFactory.create(LinkedList.class);
                value.addAll(list);
                return value;

            } else if(Collection.class.isAssignableFrom(toClass)) {
                Collection value = (Collection) beanFactory.create(ArrayList.class);
                value.addAll(list);
                return value;

            } else {
                throw new IllegalArgumentException("not support class type:" + toClass.getName());
            }

        }

        Collection value = (Collection) beanFactory.create(toClass);
        value.addAll(list);

        return value;

    }
429169
public static <T> CopyOnWriteArrayList<T> newCopyOnWriteArrayList(Collection<T> collection) {
		return (null == collection) ? (new CopyOnWriteArrayList<T>()) : (new CopyOnWriteArrayList<T>(collection));
	}
85427
public boolean registerCollection(CollectionSchema.MessageFactory factory)
    {
        return null == collectionMapping.putIfAbsent(factory.typeClass()
                .getName(), factory);
    }
667998
public static boolean notEmptyCollectionCheck(Object parameter, String error){
        if(parameter == null || (parameter instanceof Collection && ((Collection) parameter).size() == 0)){
            throw new IllegalArgumentException(error);
        }
        return true;
    }
914076
public <R, RK> List<R> fetch(Collection<DBRef<R, RK>> collection) {
        return fetch(collection, null);
    }