@Override
    protected void writeClassIdTo(Output output, Class<?> componentType, boolean array)
            throws IOException
    {
        // shouldn't happen
        assert !componentType.isArray();

        final int id = array ?
                RuntimeFieldFactory.ID_CLASS_ARRAY : RuntimeFieldFactory.ID_CLASS;

        final RegisteredDelegate<?> rd = getRegisteredDelegate(componentType);
        if (rd != null)
        {
            output.writeUInt32(id,
                    (rd.id << 5) | CID_DELEGATE, false);
            return;
        }

        final RuntimeFieldFactory<?> inline =
                RuntimeFieldFactory.getInline(componentType);

        if (inline != null)
        {
            output.writeUInt32(id,
                    getPrimitiveOrScalarId(componentType, inline.id), false);
        }
        else if (componentType.isEnum())
        {
            output.writeUInt32(id,
                    getEnumId(componentType), false);
        }
        else if (Object.class == componentType)
        {
            output.writeUInt32(id,
                    CID_OBJECT, false);
        }
        else if (Class.class == componentType)
        {
            output.writeUInt32(id,
                    CID_CLASS, false);
        }
        else if (!componentType.isInterface() &&
                !Modifier.isAbstract(componentType.getModifiers()))
        {
            output.writeUInt32(id,
                    getId(componentType), false);
        }
        else
        {
            // too many possible interfaces and abstract types that it would be costly
            // to index it at runtime (Not all subclasses allow dynamic indexing)
            // mapped class ids are +1 from regular the regular ones
            output.writeString(id + 1,
                    componentType.getName(), false);
        }
    }
Base class for numeric id strategies.

@author David Yu
@created Mar 28, 2012
protostuff-runtime-registry/src/main/java/io/protostuff/runtime/NumericIdStrategy.java