--- OBJECT TO COLLECTION CONVERTER ---
187043
protected static final Collection<?> objectToCollection(Object object) {
		Collection<?> collection = null;
		if (object != null) {
			if (object instanceof Collection) {
				collection = (Collection<?>) object;
			} else if (object instanceof Map) {
				collection = ((Map<?, ?>) object).values();
			} else if (object.getClass().isArray()) {
				LinkedList<Object> list = new LinkedList<Object>();
				int len = Array.getLength(object);
				for (int i = 0; i < len; i++) {
					list.addLast(Array.get(object, i));
				}
				collection = list;
			} else {
				collection = Collections.singleton(object);
			}
		}
		return collection;
	}
470050
private static Set<Class<?>> collectConverterClass(String scanPackageName) {
        Set<Class<?>> set = ClassUtil.getClassSet(scanPackageName);
        if (CollectionUtils.isEmpty(set)) {
            return Collections.emptySet();
        }
        Predicate<Class<?>> predicate = clazz -> clazz.isAnnotationPresent(Converter.class);
        return set.parallelStream().filter(predicate).collect(Collectors.toSet());
    }
586228
public static <T> JSONArray toJSONArray(final Collection<T> collection) {
        final JSONArray ret = new JSONArray();

        if (null == collection) {
            return ret;
        }

        for (final T object : collection) {
            ret.put(object);
        }

        return ret;
    }
1266118
@SuppressWarnings("unchecked")
    protected SFSDataWrapper transformCollection(Object value) {
        Collection<?> collection = (Collection<?>)value;
        if(collection.isEmpty())    
            return new SFSDataWrapper(SFSDataType.NULL, value);
        Iterator<?> it = collection.iterator();
        Object firstItem = it.next();
        if(firstItem.getClass().isArray())
            return transformArrayCollection(collection);
        if(isObject(firstItem.getClass())) 
            return transformObjectCollection((Collection<?>)value);
        if(firstItem instanceof Boolean)
            return new SFSDataWrapper(SFSDataType.BOOL_ARRAY, value);
        if(firstItem instanceof Byte)
            return new SFSDataWrapper(SFSDataType.BYTE_ARRAY, collectionToPrimitiveByteArray((Collection<Byte>)value));
        if(firstItem instanceof Character)
            return new SFSDataWrapper(SFSDataType.BYTE_ARRAY, charCollectionToPrimitiveByteArray((Collection<Character>)value));
        if(firstItem instanceof Double)
            return new SFSDataWrapper(SFSDataType.DOUBLE_ARRAY, value);
        if(firstItem instanceof Float)
            return new SFSDataWrapper(SFSDataType.FLOAT_ARRAY, value);
        if(firstItem instanceof Integer)
            return new SFSDataWrapper(SFSDataType.INT_ARRAY, value);
        if(firstItem instanceof Long)
            return new SFSDataWrapper(SFSDataType.LONG_ARRAY, value);
        if(firstItem instanceof Short)
            return new SFSDataWrapper(SFSDataType.SHORT_ARRAY, value);
        if(firstItem instanceof String) 
            return new SFSDataWrapper(SFSDataType.UTF_STRING_ARRAY, value);
        
        throw new IllegalArgumentException("Can not transform value of " + value.getClass());
    }
876398
public static <K, V> Collection<V> values(final Map<K, V> object) {
        return object.values();
    }
1244991
public static Collection<?> asCollection(Object obj) {

        if (obj == null) {

            return Collections.EMPTY_SET; // 返回空集合

        } else if (obj.getClass().isArray()) {

            return Arrays.asList(asArray(obj));

        } else if (obj instanceof Collection<?>) {

            return (Collection<?>) obj; // List, Set, Collection 直接返回

        } else if (obj instanceof Map<?, ?>) {

            return ((Map<?, ?>) obj).entrySet(); // 映射表， 返回条目的集合

        } else {

            return Arrays.asList(obj); // 其他类型, 返回包含单个对象的集合
        }
    }
827594
@SuppressWarnings("all")
    private static <T> T toNonCollectionType(Object data, Class<T> nonCollectionType) {
        if (Collection.class.isAssignableFrom(nonCollectionType)) {
            throw new RuntimeException("API使用错误，本方法不支持将目标对象转为非集合类型");
        }
        if (data == null) {
            return Defaults.defaultValue(nonCollectionType);
        }
        if (data.getClass().isArray()) {
            data = ArrayUtil.toList(data);
        }
        if (data instanceof Collection) {
            Collection collection = (Collection) data;
            if (nonCollectionType == String.class) {
                return (T) JSON.toJSONString(collection);
            }
            if (collection.isEmpty()) {
                return null;
            }
            if (collection.size() >= 2) {
                LOG.warn(new Throwable(String.format("集合 【 %s 】  的元素个数不只一个,我们只取出第一个做转换", data)));
            }
            for (Object element : collection) {
                LOG.debug("集合的第一个元素会被转为目标类型");
                return transferNonCollection(element, nonCollectionType);
            }
        } else {
            return transferNonCollection(data, nonCollectionType);
        }
        throw castFailedException(data, nonCollectionType);
    }
92597
public static List<ObjectFields> convertGenObjectFieldsArrayToObjectFieldsList(org.fcrepo.server.types.gen.ObjectFields[] objectFields) {
        List<ObjectFields> result = new ArrayList<ObjectFields>();
        for (org.fcrepo.server.types.gen.ObjectFields objectField : objectFields) {
            result.add(convertGenObjectFieldsToObjectFields(objectField));
        }
        return result;
    }
937236
static String toStringImpl(final Collection<?> collection) {
    StringBuilder sb = newStringBuilderForCollection(collection.size()).append('[');
    STANDARD_JOINER.appendTo(
        sb,
        Iterables.transform(
            collection,
            new Function<Object, Object>() {
              @Override
              public Object apply(Object input) {
                return input == collection ? "(this Collection)" : input;
              }
            }));
    return sb.append(']').toString();
  }
1288965
private List<Object> getCollectionValue(JsonParser jsonParser) throws IOException {
        LOG.info("Start parsing {} array", jsonParser.getCurrentName());
        List<Object> list = new ArrayList<>();
        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
            if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                Object embedded = getEmbeddedObject(jsonParser);
                list.add(embedded);
            }
            if (!"}".equals(jsonParser.getText())) {
                list.add(jsonParser.getText());
            } else {
                LOG.info("Array is over.");
            }
        }
        return list;
    }
1031532
function __Collection(iterableOrGenerator) {
                    _classCallCheck(this, __Collection);

                    //#endregion
                    //#region Iterable
                    this.__iterable = null;
                    __assert(__isIterable(iterableOrGenerator) || __isGenerator(iterableOrGenerator), 'iterable or generator', iterableOrGenerator);
                    this.__iterable = iterableOrGenerator;
                }
332714
function convertObject (schema, self) {
  var keys = Object.keys(schema);
  var ret = {};

  for (var i = 0; i < keys.length; ++i) {
    var key = keys[i];
    ret[key] = convertElement(schema[key], self);
  }

  return ret;
}
656079
public static <T> Collector<T, List<T>, List<T>> toList() {
    return Collector.of(
      ArrayList::new,
      List::add,
      (left, right) -> {
        left.addAll(right);
        return left;
      },
      ImmutableList::copyOf);
  }
1209342
public static Set<String> convertDataToSet(final Object data) {
		if (data == null) {
			return null;
		} else if (data instanceof Collection) {
			Collection items = (Collection) data;
			Set<String> set = new HashSet<>();
			for (Object item : items) {
				if (item != null) {
					set.add(item.toString());
				}
			}
			return set;
		} else if (data instanceof Object[]) {
			Object[] items = (Object[]) data;
			Set<String> set = new HashSet<>();
			for (Object item : items) {
				if (item != null) {
					set.add(item.toString());
				}
			}
			return set;
		} else {
			Set<String> set = new HashSet<>();
			set.add(data.toString());
			return set;
		}
	}
1306195
@Override
	public Collection<?> convert(Object value, Collection<?> defaultValue) throws IllegalArgumentException {
		Collection<?> result = null;
		try {
			result = convertInternal(value);
		} catch (RuntimeException e) {
			return defaultValue;
		}
		return ((null == result) ? defaultValue : result);
	}
107116
def _converter(self, value):
        
        if type(value) is not self.related_model_cls.Collection:
            value = self.related_model_cls.Collection([
                self._get_model_instance(self.related_model_cls, item)
                for item in value])
        return value
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;

    }