public static PolymorphicSchema getSchemaFromCollectionOrMapGenericType(
            Class<?> clazz, IdStrategy strategy)
    {
        if (clazz.isArray())
        {
            @SuppressWarnings("unchecked")
            Class<Object> ct = (Class<Object>) clazz.getComponentType();

            RuntimeFieldFactory<?> rff = RuntimeFieldFactory.getFieldFactory(
                    ct, strategy);

            if (rff == RuntimeFieldFactory.DELEGATE)
            {
                // delegate
                return strategy.getDelegateWrapper(ct).genericElementSchema;
            }

            if (rff.id > 0 && rff.id < 15)
            {
                // scalar
                return ArraySchemas.getGenericElementSchema(rff.id, strategy);
            }

            if (ct.isEnum())
            {
                // enum
                return strategy.getEnumIO(ct).genericElementSchema;
            }

            if (rff == RuntimeFieldFactory.POJO
                    || (rff == RuntimeFieldFactory.POLYMORPHIC_POJO && RuntimeFieldFactory
                            .pojo(ct, null, strategy)))
            {
                // pojo
                return strategy.getSchemaWrapper(ct, true).genericElementSchema;
            }

            return strategy.ARRAY_ELEMENT_SCHEMA;
        }

        if (Number.class == clazz)
            return strategy.NUMBER_ELEMENT_SCHEMA;

        if (Class.class == clazz)
            return strategy.CLASS_ELEMENT_SCHEMA;

        if (Enum.class == clazz)
            return strategy.POLYMORPHIC_ENUM_ELEMENT_SCHEMA;

        if (Object.class == clazz)
            return strategy.OBJECT_ELEMENT_SCHEMA;
        
        if (Throwable.class.isAssignableFrom(clazz))
            return strategy.POLYMORPHIC_THROWABLE_ELEMENT_SCHEMA;
        
        return null;
    }
Polymorphic types.

@author David Yu
@created Apr 30, 2012
protostuff-runtime/src/main/java/io/protostuff/runtime/PolymorphicSchemaFactories.java