Converts a String representation to collection of
<code>genericClass</code> objects

@param input
@param collectionClass
@param genericClass
@param mediaType
@return
194438
public static Collection toCollection(String input, Class<?> collectionClass, Class<?> genericClass,
            String mediaType)
    {

        try
        {
            if (MediaType.APPLICATION_XML.equals(mediaType))
            {
                Collection c = (Collection) collectionClass.newInstance();
                if (input.startsWith("<?xml"))
                {
                    input = input.substring(input.indexOf(">") + 1, input.length());
                }

                input = input.replaceAll("<" + genericClass.getSimpleName().toLowerCase() + "s>", "");

                while (!input.equals(""))
                {
                    int i = input.indexOf("</" + genericClass.getSimpleName().toLowerCase() + ">");
                    String s = input.substring(0, i + 3 + genericClass.getSimpleName().length());
                    input = input.substring(i + 3 + genericClass.getSimpleName().length(), input.length());
                    Object o = JAXBUtils.toObject(StreamUtils.toInputStream(s), genericClass, mediaType);
                    c.add(o);
                }
                return c;

            }
            else if (MediaType.APPLICATION_JSON.equals(mediaType))
            {
                
                    return  JAXBUtils.mapper.readValue(input, JAXBUtils.mapper.getTypeFactory()
                                        .constructCollectionType((Class<? extends Collection>) collectionClass, genericClass));
               
                
            }
            return null;
        }
        catch (InstantiationException e)
        {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        }
        catch (IllegalAccessException e)
        {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        } catch (JsonParseException e) {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        } catch (JsonMappingException e) {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        } catch (IOException e) {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        }
    }
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;
    }
1181797
@Override
	public <L extends Collection<E>, E> L parseCollection(byte[] source, L collection, Class<E> type) {
		if (collection == null || type == null)
			return null;

		try (ParserWrapper parserWrapper = createParser(source)) {
			L result = mapperFor(type).parseCollection(this, parserWrapper, collection);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			throw new KriptonRuntimeException(e);
		}
	}
401132
public static boolean isODataEntityCollectionType(Class<?> type,
            Type genericType) {
        if (ListResult.class != type) {
            return false;
        }

        ParameterizedType pt = (ParameterizedType) genericType;

        if (pt.getActualTypeArguments().length != 1) {
            return false;
        }

        Class<?> typeClass = getCollectedType(genericType);

        return isODataEntityType(typeClass);
    }
1281331
public <T extends TypeDefinition> List<T> getTypes(Class<T> targetClass) {
        return types.values().stream()
                .filter(targetClass::isInstance)
                .map(targetClass::cast)
                .collect(Collectors.toList());
    }
1096772
public <A, E extends SimpleExpression<A>> CollectionPath<A, E> getCollection(String property, Class<A> type, Class<? super E> queryType) {
        validate(property, Collection.class);
        return super.createCollection(property, type, queryType, PathInits.DIRECT);
    }
764417
public static Class<?> getListInnerClassFromGenericType(Type genericType) {
        ParameterizedType innerClass = (ParameterizedType) genericType;
        return (Class<?>) innerClass.getActualTypeArguments()[0];
    }
637362
public <T extends AbstractJaxb> List<T> getByNameAsList(String name, Class<T> tagType) {
        return GetByNameUtil.getByNameAsList((T) this, new ArrayList<T>(), name,tagType);
    }
850139
@SuppressWarnings("rawtypes")
	public static Class<?> getCollectionType(Class<? extends Collection> collectionClass) {
		return ResolvableType.forClass(collectionClass).asCollection().resolveGeneric();
	}
216667
protected T get(Class<?> type,
	                Class<? extends T> byDefinition,
	                InjectionProvider provider,
	                RoutingContext routeContext,
	                MediaType[] mediaTypes) throws ClassFactoryException,
	                                               ContextException {

		Class<? extends T> clazz = byDefinition;

		// No class defined ... try by type
		if (clazz == null) {
			clazz = get(type);
		}

		// try with media type ...
		if (clazz == null && mediaTypes != null && mediaTypes.length > 0) {

			for (MediaType mediaType : mediaTypes) {
				clazz = get(mediaType);

				if (clazz != null) {
					break;
				}
			}
		}

		if (clazz != null) {
			return getClassInstance(clazz, provider, routeContext);
		}

		// 3. find cached instance ... if any
		return cache.get(type.getName());
	}
1149892
public static <T> Function<Object, Collection<T>> COLLECTION(final Class<? extends Collection> collectionType, final Class<T> componentType) {
      return new CollectionConverterImpl<>(collectionType, componentType);
   }
548086
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders,
			InputStream entityStream) throws IOException, WebApplicationException {
		String input = null;
		try {
			input = IOUtils.inputStreamToString(entityStream);
		} catch (Exception e) {
			
		}
		if (input == null) {
            return null;
        }
		if (fastJsonConfig.features == null)
			return JSON.parseObject(input, type, fastJsonConfig.parserConfig, JSON.DEFAULT_PARSER_FEATURE);
		else
			return JSON.parseObject(input, type, fastJsonConfig.parserConfig, JSON.DEFAULT_PARSER_FEATURE, fastJsonConfig.features);
	}
743965
public static Function<Object, Collection<?>> COLLECTION(final Class<? extends Collection> collectionType) {
      return as(new CollectionConverterImpl<>(collectionType, null));
   }
824422
@Override
    public <T> Collection<T> all(Class<T> serviceClass) {
        List<T> serviceImpls = new ArrayList<T>();
        Set<Class<? extends T>> serviceImplClasses = registry.getServiceImpls(serviceClass);
        for (Class<? extends T> serviceImplClass : serviceImplClasses) {
            T serviceImpl = createServiceInstance(serviceImplClass);
            serviceImpls.add(serviceImpl);
        }
        return serviceImpls;
    }
1293354
@SuppressWarnings("unchecked")
	protected static <E> Class<? extends E> extractClassFrom(Collection<? extends E> collection) {
		Class<? extends E> clazz = null;
		for (final E elt : collection) {
			clazz = (Class<? extends E>) ReflectionUtil.getCommonType(clazz, elt.getClass());
		}
		return clazz == null ? (Class<E>) Object.class : clazz;
	}
431406
public static Collection<?> toCollection(Class<?> collectionType, Class<?> elementType, Object value) {
		return new CollectionConverter(collectionType, elementType).convert(value, null);
	}
1216128
protected Class<?> getCollectionElementType(Type genericType) throws ConversionException {
        if (genericType instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) genericType;
            Type[] typeArguments = parameterizedType.getActualTypeArguments();
            if (typeArguments.length != 1) {
                throw new ConversionException("Types with more then one generic are not supported");
            }

            Type type = typeArguments[0];
            if (type instanceof Class) {
                return (Class<?>) type;
            }

            throw new ConversionException(String.format("Could not resolve generic type <%s>", type));
        }
        return String.class;
    }