Listのインスタンスを他のCollectionのインスタンスに変換する。
<p>ただし、変換先のクラスタイプがインタフェースの場合は変換しない。
<p>変換元のクラスと変換先のクラスが同じ場合は、変換しない。

@since 1.0
@param list 変換元のListのインスタンス
@param toClass 変換先のCollectionのクラス
@param beanFactory てインスタンスを生成するファクトリクラス。
@return 変換したコレクションのインスタンス
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;

    }
1235872
@SneakyThrows
    public static <T extends Collection> T toCollection(final Object obj, final Class<T> clazz) {
        val results = toCollection(obj);
        if (clazz.isInterface()) {
            throw new IllegalArgumentException("Cannot accept an interface " + clazz.getSimpleName() + " to create a new object instance");
        }
        val col = clazz.getDeclaredConstructor().newInstance();
        col.addAll(results);
        return col;
    }
314507
private List<Field> getList(Map<Class<?>, List<Field>> fields) {
        List<Field> ret = fields == null ? null : fields.get(getServiceClass());
        if (ret != null) {
            ret = Collections.unmodifiableList(ret);
        } else {
            ret = Collections.emptyList();
        }
        return ret;
    }
1268731
public static List<Class<?>> getGenericClasses(Field collectionField)
    {
        List<Class<?>> genericClasses = new ArrayList<Class<?>>();
        if (collectionField == null)
        {
            return genericClasses;
        }
        Type[] parameters = ReflectUtils.getTypeArguments(collectionField);
        if (parameters != null)
        {

            for (Type parameter : parameters)
            {
                // workaround for jdk1.6 issue.
                genericClasses.add(toClass(parameter));
            }
        }
        return genericClasses;
    }
1040859
List<JCClassDecl> listClasses(List<JCCompilationUnit> trees) {
        ListBuffer<JCClassDecl> result = new ListBuffer<>();
        for (JCCompilationUnit t : trees) {
            for (JCTree def : t.defs) {
                if (def.hasTag(JCTree.Tag.CLASSDEF))
                    result.append((JCClassDecl)def);
            }
        }
        return result.toList();
    }
245905
protected <T> List<T> toArrayList(List<T> list) {
        if (list == null) {
            return null;
        }
        if (!list.getClass().equals(ArrayList.class)) {
            list = new ArrayList<>(list);
        }
        return list;
    }
989169
public <T> List<T> dataToTypedList(Class<T> type) {
        return Reflection.toTypedList(data, type);
    }
413514
public static final <T> T assignList(Object bean, String property, String hint, BiFunction<Class<T>,String,T> factory)
    {
        Class[] pt = getParameterTypes(bean, prefix(property));
        Class type = pt != null && pt.length > 0 ? pt[0] : null;
        T value = (T) factory.apply(type, hint);
        doFor(
            bean, 
            property, 
            null,
            (Object a, int i)->{Array.set(a, i, value);return null;},
            (List l, int i)->{l.set(i, value);return null;},
            (Object b, Class c, String p)->{throw  new UnsupportedOperationException("not supported");},
            (Object b, Method m)->{throw  new UnsupportedOperationException("not supported");}
        );
        return value;
    }
721450
@SuppressWarnings({"unchecked", "rawtypes"})
    public List<E> getValueAsList() {

        final Object fieldValue = getValue();
        final Class<?> fieldType = getType();

        if(Collection.class.isAssignableFrom(fieldType)) {
            final Collection<Object> value = (fieldValue == null ? new ArrayList<Object>() : (Collection<Object>) fieldValue);
            final List<Object> list = Utils.convertCollectionToList(value);
            return (List)list;

        } else if(fieldType.isArray()) {
            Class<?> componentType = fieldType.getComponentType();
            final List<Object> list = Utils.asList(fieldValue, componentType);
            return (List)list;

        } else {
            throw new IllegalStateException(MessageBuilder.create("validation.notSupportType")
                    .var("property", getFieldPath())
                    .varWithClass("type", fieldType)
                    .format());
        }

    }
26601
public <T> List<T> filterToList(Object source, Class<T> filter) {
        Validate.argumentsAreNotNull(filter);

        return (List) unmodifiableList(
        items(source).filter(item -> item!=null && filter.isAssignableFrom(item.getClass()))
                     .collect(Collectors.toList()));
    }
213747
public <T> List<T> getBeans(Class<T> klass) {
        List<T> list = new ArrayList<>();
        for (String name : getIoc().getNamesByType(klass)) {
            if (name == null)
                continue;
            list.add(getIoc().get(klass, name));
        }
        return list;
    }
1192827
public <T> List<T> getList(String name, Class<T> type) {

		Object value = super.get(name);

		// make sure correct objects are returned
		if (value instanceof List) {

			ArrayList<T> output = new ArrayList<>();

			List list = (List) value;
			for (Object item : list) {
				output.add(type.cast(item));
			}

			return output;
		}

		throw new IllegalArgumentException("Setting: '" + name + "', can't be converted to List<" + type.getName() + ">: '" + value + "'!");
	}
1221245
@SuppressWarnings("unchecked")
   public <T> List<T> asList(Class<T> itemType) {
      return asCollection(List.class, itemType);
   }
314139
public static <E, T> List<E> convert(List<T> source, Class<E> targetClass) {
        return BeansConvertStrategy.convertBeans(source, targetClass, false);
    }
18277
@Override
	public NamingEnumeration<NameClassPair> list(Name name) throws NamingException
    {
        if (name.isEmpty())
            return new ListOfNames(bindings.keys());

        Object target = lookup(name);
        if (target instanceof Context)
        {
            try
            {
                return ((Context)target).list("");
            }
            finally
            {
                ((Context)target).close();
            }
        }
        throw new NotContextException(name + " cannot be listed");
    }
858582
private static <T> List<TableFactory> filterByFactoryClass(
		Class<T> factoryClass,
		Map<String, String> properties,
		List<TableFactory> foundFactories) {

		List<TableFactory> classFactories = foundFactories.stream()
			.filter(p -> factoryClass.isAssignableFrom(p.getClass()))
			.collect(Collectors.toList());

		if (classFactories.isEmpty()) {
			throw new NoMatchingTableFactoryException(
				String.format("No factory implements '%s'.", factoryClass.getCanonicalName()),
				factoryClass,
				foundFactories,
				properties);
		}

		return classFactories;
	}
759150
@NonNull
    @Override
    public List<Object> toList() {
        final List<Object> array = new ArrayList<>();
        for (int i = 0; i < count(); i++) {
            array.add(values.get(i).asObject());
        }
        return array;
    }