@Override
        public PolymorphicSchema newSchema(Class<?> typeClass,
                IdStrategy strategy, final Handler handler)
        {
            @SuppressWarnings("unchecked")
            Class<Object> ct = (Class<Object>) typeClass.getComponentType();

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

            if (rff == RuntimeFieldFactory.DELEGATE)
            {
                // delegate
                return strategy.getDelegateWrapper(ct).newSchema(typeClass,
                        strategy, handler);
            }

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

            if (ct.isEnum())
            {
                // enum
                return strategy.getEnumIO(ct).newSchema(typeClass, strategy,
                        handler);
            }

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

            return new ArraySchema(strategy)
            {
                @Override
                protected void setValue(Object value, Object owner)
                {
                    handler.setValue(value, owner);
                }
            };
        }
Polymorphic types.

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