Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   package io.protostuff.runtime;
   
   import java.io.IOException;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Map;
   import java.util.Map.Entry;
   
This base class handles all the IO for reading and writing polymorphic fields. When a field's type is polymorphic/dynamic (e.g interface/abstract/object), the type (id) needs to be written (ahead) before its value/content to be able to deserialize it correctly.

The underlying impl will determine how the type (id) should be written.

An IdStrategy is standalone if the primaryGroup is not set.

Author(s):
Leo Romanoff
David Yu
  
  public abstract class IdStrategy
  {
  
      public final IdStrategy primaryGroup;
      public final int groupId;
  
      protected IdStrategy(IdStrategy primaryGroupint groupId)
      {
          if (primaryGroup != null)
          {
              if (groupId <= 0 || 0 != (groupId & (groupId - 1)))
              {
                  throw new RuntimeException(
                          "The groupId must be a power of two (1,2,4,8,etc).");
              }
          }
          else if (groupId != 0)
          {
              throw new RuntimeException("An IdStrategy without a primaryGroup "
                      + "(standalone) must have a groupId of zero.");
          }
  
          this. = primaryGroup;
          this. = groupId;
      }

    
Generates a schema from the given class. If this strategy is part of a group, the existing fields of that group's schema will be re-used.
  
      protected <T> Schema<T> newSchema(Class<T> typeClass)
      {
          // check if this is part of a group
          if ( != null)
          {
              // only pojos created by runtime schema support groups
              final Schema<T> s = .getSchemaWrapper(typeClasstrue)
                      .getSchema();
              if (s instanceof RuntimeSchema)
              {
                  final RuntimeSchema<T> rs = (RuntimeSchema<T>) s;
  
                  final ArrayList<Field<T>> fields = new ArrayList<>(rs.getFieldCount());
  
                  for (Field<T> f : rs.getFields())
                  {
                      final int groupFilter = f.groupFilter;
                      if (groupFilter != 0)
                      {
                          final int set// set for exclusion
                          if (groupFilter > 0)
                          {
                              // inclusion
                              set = ~groupFilter & 0x7FFFFFFF;
                          }
                          else
                          {
                              // exclusion
                              set = -groupFilter;
                          }
  
                          if (0 != ( & set))
                          {
                              // this field is excluded on the current group id
                              continue;
                          }
                      }
 
                     fields.add(f);
                 }
 
                 final int size = fields.size();
                 if (size == rs.getFieldCount())
                 {
                     // nothing is excluded
                     return rs;
                 }
 
                 if (size == 0)
                 {
                     throw new RuntimeException("All fields were excluded for "
                             + rs.messageFullName() + " on group " + );
                 }
 
                 return new RuntimeSchema<>(typeClassfieldsrs.instantiator);
             }
 
             return s;
         }
 
         return RuntimeSchema.createFrom(typeClassthis);
     }

    
Thrown when a type is not known by the IdStrategy. The DefaultIdStrategy will never throw this exception though.
 
     public static class UnknownTypeException extends RuntimeException
     {
         private static final long serialVersionUID = 1L;
 
         public UnknownTypeException(String msg)
         {
             super(msg);
         }
     }

    
Responsible for instantiating custom IdStrategy impls.
 
     public interface Factory
     {
        
Creates a new IdStrategy instance (impl).
 
         public IdStrategy create();

        
Called after the method create() has been called. This is used to prevent classloader issues. RuntimeEnv's RuntimeEnv.ID_STRATEGY need to be set first.
 
         public void postCreate();
     }

    
Returns true if there is a Delegate explicitly registered for the typeClass.
 
     public abstract boolean isDelegateRegistered(Class<?> typeClass);

    
Returns the delegate.
 
     public abstract <T> HasDelegate<T> getDelegateWrapper(
             Class<? super T> typeClass);

    
Returns the delegate.
 
     public abstract <T> Delegate<T> getDelegate(Class<? super T> typeClass);

    
Returns true if the typeClass is explicitly registered.
 
     public abstract boolean isRegistered(Class<?> typeClass);

    
Returns the schema wrapper. The caller is responsible that the typeClass is a pojo (e.g not an enum/array/etc).
 
     public abstract <T> HasSchema<T> getSchemaWrapper(Class<T> typeClass,
             boolean create);

    
Returns the EnumIO. The callers (internal field factories) are responsible that the class provided is an enum class.
 
     protected abstract EnumIO<? extends Enum<?>> getEnumIO(Class<?> enumClass);

    
Returns the io.protostuff.CollectionSchema.MessageFactory. The callers (internal field factories) are responsible that the class provided implements java.util.Collection.
 
             Class<?> clazz);

    
Returns the io.protostuff.MapSchema.MessageFactory. The callers (internal field factories}) are responsible that the class provided implements java.util.Map.
 
     protected abstract MapSchema.MessageFactory getMapFactory(Class<?> clazz);
 
     // collection
 
     protected abstract void writeCollectionIdTo(Output outputint fieldNumber,
             Class<?> clazzthrows IOException;
 
     protected abstract void transferCollectionId(Input inputOutput output,
             int fieldNumberthrows IOException;
 
             Input inputthrows IOException;
 
     // map
 
     protected abstract void writeMapIdTo(Output outputint fieldNumber,
             Class<?> clazzthrows IOException;
 
     protected abstract void transferMapId(Input inputOutput output,
             int fieldNumberthrows IOException;
 
     protected abstract MapSchema.MessageFactory resolveMapFrom(Input input)
             throws IOException;
 
     // enum
 
     protected abstract void writeEnumIdTo(Output outputint fieldNumber,
             Class<?> clazzthrows IOException;
 
     protected abstract void transferEnumId(Input inputOutput output,
             int fieldNumberthrows IOException;
 
     protected abstract EnumIO<?> resolveEnumFrom(Input input)
             throws IOException;
 
     // pojo
 
     protected abstract <T> HasSchema<T> writePojoIdTo(Output output,
             int fieldNumberClass<T> clazzthrows IOException;
 
     protected abstract <T> HasSchema<T> transferPojoId(Input input,
             Output outputint fieldNumberthrows IOException;
 
     protected abstract <T> HasSchema<T> resolvePojoFrom(Input input,
             int fieldNumberthrows IOException;
 
     protected abstract <T> Schema<T> writeMessageIdTo(Output output,
             int fieldNumberMessage<T> messagethrows IOException;
 
     // delegate
 
    
If this method returns null, the clazz was not registered as a delegate.
 
     protected abstract <T> HasDelegate<T> tryWriteDelegateIdTo(Output output,
             int fieldNumberClass<T> clazzthrows IOException;
 
     protected abstract <T> HasDelegate<T> transferDelegateId(Input input,
             Output outputint fieldNumberthrows IOException;
 
     protected abstract <T> HasDelegate<T> resolveDelegateFrom(Input input)
             throws IOException;
 
     // array
 
     protected abstract void writeArrayIdTo(Output outputClass<?> componentType)
             throws IOException;
 
     protected abstract void transferArrayId(Input inputOutput output,
             int fieldNumberboolean mappedthrows IOException;
 
     protected abstract Class<?> resolveArrayComponentTypeFrom(Input input,
             boolean mappedthrows IOException;
 
     // class
 
     protected abstract void writeClassIdTo(Output output,
             Class<?> componentTypeboolean arraythrows IOException;
 
     protected abstract void transferClassId(Input inputOutput output,
             int fieldNumberboolean mappedboolean arraythrows IOException;
 
     protected abstract Class<?> resolveClassFrom(Input inputboolean mapped,
             boolean arraythrows IOException;
 
     // polymorphic requirements
 
             this)
     {
         @Override
         @SuppressWarnings("unchecked")
         protected void doMergeFrom(Input inputSchema<ObjectderivedSchema,
                 Object ownerthrows IOException
         {
             final Object value = derivedSchema.newMessage();
 
             if (MapWrapper.class == owner.getClass())
                 ((MapWrapper<ObjectObject>) owner).setValue(value);
             else
                 ((Collection<Object>) owner).add(value);
 
             if (input instanceof GraphInput)
             {
                 // update the actual reference.
                 ((GraphInputinput).updateLast(valueowner);
             }
 
             derivedSchema.mergeFrom(inputvalue);
         }
     };
 
     // object polymorphic schema requirements
 
     final ArraySchema ARRAY_ELEMENT_SCHEMA = new ArraySchema(this)
     {
         @Override
         @SuppressWarnings("unchecked")
         protected void setValue(Object valueObject owner)
         {
             if (MapWrapper.class == owner.getClass())
                 ((MapWrapper<ObjectObject>) owner).setValue(value);
             else
                 ((Collection<Object>) owner).add(value);
         }
     };
 
     final NumberSchema NUMBER_ELEMENT_SCHEMA = new NumberSchema(this)
     {
         @Override
         @SuppressWarnings("unchecked")
         protected void setValue(Object valueObject owner)
         {
             if (MapWrapper.class == owner.getClass())
                 ((MapWrapper<ObjectObject>) owner).setValue(value);
             else
                 ((Collection<Object>) owner).add(value);
         }
     };
 
     final ClassSchema CLASS_ELEMENT_SCHEMA = new ClassSchema(this)
     {
         @Override
         @SuppressWarnings("unchecked")
         protected void setValue(Object valueObject owner)
         {
             if (MapWrapper.class == owner.getClass())
                 ((MapWrapper<ObjectObject>) owner).setValue(value);
             else
                 ((Collection<Object>) owner).add(value);
         }
     };
 
             this)
     {
         @Override
         @SuppressWarnings("unchecked")
         protected void setValue(Object valueObject owner)
         {
             if (MapWrapper.class == owner.getClass())
                 ((MapWrapper<ObjectObject>) owner).setValue(value);
             else
                 ((Collection<Object>) owner).add(value);
         }
     };
 
             this)
     {
         @Override
         @SuppressWarnings("unchecked")
         protected void setValue(Object valueObject owner)
         {
             if (MapWrapper.class == owner.getClass())
                 ((MapWrapper<ObjectObject>) owner).setValue(value);
             else
                 ((Collection<Object>) owner).add(value);
         }
     };
 
     final ObjectSchema OBJECT_ELEMENT_SCHEMA = new ObjectSchema(this)
     {
         @Override
         @SuppressWarnings("unchecked")
         protected void setValue(Object valueObject owner)
         {
             if (MapWrapper.class == owner.getClass())
                 ((MapWrapper<ObjectObject>) owner).setValue(value);
             else
                 ((Collection<Object>) owner).add(value);
         }
     };
 
     // object dynamic schema requirements
 
     final Schema<ObjectDYNAMIC_VALUE_SCHEMA = new Schema<Object>()
     {
         @Override
         public String getFieldName(int number)
         {
             return ObjectSchema.name(number);
         }
 
         @Override
         public int getFieldNumber(String name)
         {
             return ObjectSchema.number(name);
         }
 
         @Override
         public boolean isInitialized(Object owner)
         {
             return true;
         }
 
         @Override
         public String messageFullName()
         {
             return Object.class.getName();
         }
 
         @Override
         public String messageName()
         {
             return Object.class.getSimpleName();
         }
 
         @Override
         public Object newMessage()
         {
             // cannot instantiate because the type is dynamic.
             throw new UnsupportedOperationException();
         }
 
         @Override
         public Class<? super ObjecttypeClass()
         {
             return Object.class;
         }
 
         @Override
         @SuppressWarnings("unchecked")
         public void mergeFrom(Input inputObject ownerthrows IOException
         {
             if (PMapWrapper.class == owner.getClass())
             {
                 // called from ENTRY_SCHEMA
                 ((PMapWrapperowner).setValue(ObjectSchema.readObjectFrom(
                         inputthisownerIdStrategy.this));
             }
             else
             {
                 // called from COLLECTION_SCHEMA
                 ((Collection<Object>) owner).add(ObjectSchema.readObjectFrom(
                         inputthisownerIdStrategy.this));
             }
         }
 
         @Override
         public void writeTo(Output outputObject messagethrows IOException
         {
             ObjectSchema.writeObjectTo(outputmessagethisIdStrategy.this);
         }
     };
 
             )
     {
         @Override
         protected void transfer(Pipe pipeInput inputOutput output)
                 throws IOException
         {
             ObjectSchema.transferObject(thispipeinputoutput,
                     IdStrategy.this);
         }
     };
 
     {
         @Override
         public String getFieldName(int number)
         {
             return number == 1 ? . : null;
         }
 
         @Override
         public int getFieldNumber(String name)
         {
             return name.length() == 1 && name.charAt(0) == 'v' ? 1 : 0;
         }
 
         @Override
         public boolean isInitialized(Collection<Objectowner)
         {
             return true;
         }
 
         @Override
         public String messageFullName()
         {
             return Collection.class.getName();
         }
 
         @Override
         public String messageName()
         {
             return Collection.class.getSimpleName();
         }
 
         @Override
         public Collection<ObjectnewMessage()
         {
             throw new UnsupportedOperationException();
         }
 
         @Override
         public Class<? super Collection<Object>> typeClass()
         {
             return Collection.class;
         }
 
         @Override
         public void mergeFrom(Input inputCollection<Objectmessage)
                 throws IOException
         {
             for (int number = input.readFieldNumber(this);; number = input
                     .readFieldNumber(this))
             {
                 switch (number)
                 {
                     case 0:
                         return;
                     case 1:
                         final Object value = input.mergeObject(message,
                                 );
                         if (input instanceof GraphInput
                                 && ((GraphInputinput).isCurrentMessageReference())
                         {
                             // a reference from polymorphic+cyclic graph deser
                             message.add(value);
                         }
                         break;
                     default:
                         throw new ProtostuffException("Corrupt input.");
                 }
             }
         }
 
         @Override
         public void writeTo(Output outputCollection<Objectmessage)
                 throws IOException
         {
             for (Object value : message)
             {
                 if (value != null)
                     output.writeObject(1, valuetrue);
             }
         }
     };
 
             )
     {
         @Override
         protected void transfer(Pipe pipeInput inputOutput output)
                 throws IOException
         {
             for (int number = input.readFieldNumber();; number = input
                     .readFieldNumber())
             {
                 switch (number)
                 {
                     case 0:
                         return;
                     case 1:
                         output.writeObject(numberpipe,
                                 true);
                         break;
                     default:
                         throw new ProtostuffException(
                                 "The collection was incorrectly " + "serialized.");
                 }
             }
         }
     };
 
     final Schema<ObjectARRAY_SCHEMA = new Schema<Object>()
     {
         @Override
         public String getFieldName(int number)
         {
             return number == 1 ? . : null;
         }
 
         @Override
         public int getFieldNumber(String name)
         {
             return name.length() == 1 && name.charAt(0) == 'v' ? 1 : 0;
         }
 
         @Override
         public boolean isInitialized(Object owner)
         {
             return true;
         }
 
         @Override
         public String messageFullName()
         {
             return Array.class.getName();
         }
 
         @Override
         public String messageName()
         {
             return Array.class.getSimpleName();
         }
 
         @Override
         public Object newMessage()
         {
             throw new UnsupportedOperationException();
         }
 
         @Override
         public Class<? super ObjecttypeClass()
         {
             return Object.class;
         }
 
         @Override
         public void mergeFrom(Input inputObject messagethrows IOException
         {
             // using COLLECTION_SCHEMA instead.
             throw new UnsupportedOperationException();
         }
 
         @Override
         public void writeTo(Output outputObject messagethrows IOException
         {
             for (int i = 0, len = Array.getLength(message); i < leni++)
             {
                 final Object value = Array.get(messagei);
                 if (value != null)
                 {
                     output.writeObject(1, valuetrue);
                 }
             }
         }
     };
 
     final Pipe.Schema<ObjectARRAY_PIPE_SCHEMA = new Pipe.Schema<Object>(
             )
     {
         @Override
         protected void transfer(Pipe pipeInput inputOutput output)
                 throws IOException
         {
             for (int number = input.readFieldNumber();; number = input
                     .readFieldNumber())
             {
                 switch (number)
                 {
                     case 0:
                         return;
                     case 1:
                         output.writeObject(numberpipe,
                                 true);
                         break;
                     default:
                         throw new ProtostuffException("The array was incorrectly "
                                 + "serialized.");
                 }
             }
         }
     };
 
     final Schema<Map<ObjectObject>> MAP_SCHEMA = new Schema<Map<ObjectObject>>()
     {
         @Override
         public final String getFieldName(int number)
         {
             return number == 1 ? . : null;
         }
 
         @Override
         public final int getFieldNumber(String name)
         {
             return name.length() == 1 && name.charAt(0) == 'e' ? 1 : 0;
         }
 
         @Override
         public boolean isInitialized(Map<ObjectObjectowner)
         {
             return true;
         }
 
         @Override
         public String messageFullName()
         {
             return Map.class.getName();
         }
 
         @Override
         public String messageName()
         {
             return Map.class.getSimpleName();
         }
 
         @Override
         public Map<ObjectObjectnewMessage()
         {
             throw new UnsupportedOperationException();
         }
 
         @Override
         public Class<? super Map<ObjectObject>> typeClass()
         {
             return Map.class;
         }
 
         @Override
         public void mergeFrom(Input inputMap<ObjectObjectmessage)
                 throws IOException
         {
             PMapWrapper entry = null;
             for (int number = input.readFieldNumber(this);; number = input
                     .readFieldNumber(this))
             {
                 switch (number)
                 {
                     case 0:
                         return;
                     case 1:
                         if (entry == null)
                         {
                             // lazy initialize
                             entry = new PMapWrapper(message);
                         }
 
                         if (entry != input.mergeObject(entry))
                         {
                             // an entry will always be unique
                             // it can never be a reference.
                             throw new IllegalStateException(
                                     "A Map.Entry will always be "
                                             + "unique, hence it cannot be a reference "
                                             + "obtained from "
                                             + input.getClass().getName());
                         }
                         break;
                     default:
                         throw new ProtostuffException(
                                 "The map was incorrectly serialized.");
                 }
             }
         }
 
         @Override
         public void writeTo(Output outputMap<ObjectObjectmessage)
                 throws IOException
         {
             for (Map.Entry<ObjectObjectentry : message.entrySet())
             {
                 output.writeObject(1, entrytrue);
             }
         }
     };
 
     final Pipe.Schema<Map<ObjectObject>> MAP_PIPE_SCHEMA = new Pipe.Schema<Map<ObjectObject>>(
             )
     {
         @Override
         protected void transfer(Pipe pipeInput inputOutput output)
                 throws IOException
         {
             for (int number = input.readFieldNumber();; number = input
                     .readFieldNumber())
             {
                 switch (number)
                 {
                     case 0:
                         return;
                     case 1:
                         output.writeObject(numberpipetrue);
                         break;
                     default:
                         throw new ProtostuffException("The map was incorrectly "
                                 + "serialized.");
                 }
             }
         }
     };
 
     final Schema<Entry<ObjectObject>> ENTRY_SCHEMA = new Schema<Entry<ObjectObject>>()
     {
         @Override
         public final String getFieldName(int number)
         {
             switch (number)
             {
                 case 1:
                     return .;
                 case 2:
                     return .;
                 default:
                     return null;
             }
         }
 
         @Override
         public final int getFieldNumber(String name)
         {
             if (name.length() != 1)
                 return 0;
 
             switch (name.charAt(0))
             {
                 case 'k':
                     return 1;
                 case 'v':
                     return 2;
                 default:
                     return 0;
             }
         }
 
         @Override
         public boolean isInitialized(Entry<ObjectObjectmessage)
         {
             return true;
         }
 
         @Override
         public String messageFullName()
         {
             return Entry.class.getName();
         }
 
         @Override
         public String messageName()
         {
             return Entry.class.getSimpleName();
         }
 
         @Override
         public Entry<ObjectObjectnewMessage()
         {
             throw new UnsupportedOperationException();
         }
 
         @Override
         public Class<? super Entry<ObjectObject>> typeClass()
         {
             return Entry.class;
         }
 
         @Override
         public void mergeFrom(Input inputEntry<ObjectObjectmessage)
                 throws IOException
         {
             // Nobody else calls this except MAP_SCHEMA.mergeFrom
             final PMapWrapper entry = (PMapWrappermessage;
 
             Object key = nullvalue = null;
             for (int number = input.readFieldNumber(this);; number = input
                     .readFieldNumber(this))
             {
                 switch (number)
                 {
                     case 0:
                         entry.map.put(keyvalue);
                         return;
                     case 1:
                         if (key != null)
                         {
                             throw new ProtostuffException(
                                     "The map was incorrectly " + "serialized.");
                         }
                         key = input.mergeObject(entry);
                         if (entry != key)
                         {
                             // a reference.
                             assert key != null;
                         }
                         else
                         {
                             // entry held the key
                             key = entry.setValue(null);
                             assert key != null;
                         }
                         break;
                     case 2:
                         if (value != null)
                         {
                             throw new ProtostuffException(
                                     "The map was incorrectly " + "serialized.");
                         }
                         value = input.mergeObject(entry);
                         if (entry != value)
                         {
                             // a reference.
                             assert value != null;
                         }
                         else
                         {
                             // entry held the value
                             value = entry.setValue(null);
                             assert value != null;
                         }
                         break;
                     default:
                         throw new ProtostuffException("The map was incorrectly "
                                 + "serialized.");
                 }
             }
         }
 
         @Override
         public void writeTo(Output outputEntry<ObjectObjectentry)
                 throws IOException
         {
             if (entry.getKey() != null)
                 output.writeObject(1, entry.getKey(), ,
                         false);
 
             if (entry.getValue() != null)
                 output.writeObject(2, entry.getValue(), ,
                         false);
         }
     };
 
             )
     {
         @Override
         protected void transfer(Pipe pipeInput inputOutput output)
                 throws IOException
         {
             for (int number = input.readFieldNumber();; number = input
                     .readFieldNumber())
             {
                 switch (number)
                 {
                     case 0:
                         return;
                     case 1:
                         output.writeObject(numberpipe,
                                 false);
                         break;
                     case 2:
                         output.writeObject(numberpipe,
                                 false);
                         break;
                     default:
                         throw new ProtostuffException("The map was incorrectly "
                                 + "serialized.");
                 }
             }
         }
     };
 
     final Schema<ObjectOBJECT_SCHEMA = new Schema<Object>()
     {
         @Override
         public String getFieldName(int number)
         {
             return ObjectSchema.name(number);
         }
 
         @Override
         public int getFieldNumber(String name)
         {
             return ObjectSchema.number(name);
         }
 
         @Override
         public boolean isInitialized(Object owner)
         {
             return true;
         }
 
         @Override
         public String messageFullName()
         {
             return Object.class.getName();
         }
 
         @Override
         public String messageName()
         {
             return Object.class.getSimpleName();
         }
 
         @Override
         public Object newMessage()
         {
             // cannot instantiate because the type is dynamic.
            throw new UnsupportedOperationException();
        }
        @Override
        public Class<? super ObjecttypeClass()
        {
            return Object.class;
        }
        @Override
        public void mergeFrom(Input inputObject ownerthrows IOException
        {
            ((Wrapperowner). = ObjectSchema.readObjectFrom(inputthis,
                    ownerIdStrategy.this);
        }
        @Override
        public void writeTo(Output outputObject messagethrows IOException
        {
            ObjectSchema.writeObjectTo(outputmessagethisIdStrategy.this);
        }
    };
            )
    {
        @Override
        protected void transfer(Pipe pipeInput inputOutput output)
                throws IOException
        {
            ObjectSchema.transferObject(thispipeinputoutput,
                    IdStrategy.this);
        }
    };
    final Schema<ObjectCLASS_SCHEMA = new Schema<Object>()
    {
        @Override
        public String getFieldName(int number)
        {
            return ClassSchema.name(number);
        }
        @Override
        public int getFieldNumber(String name)
        {
            return ClassSchema.number(name);
        }
        @Override
        public boolean isInitialized(Object owner)
        {
            return true;
        }
        @Override
        public String messageFullName()
        {
            return Class.class.getName();
        }
        @Override
        public String messageName()
        {
            return Class.class.getSimpleName();
        }
        @Override
        public Object newMessage()
        {
            // cannot instantiate because the type is dynamic.
            throw new UnsupportedOperationException();
        }
        @Override
        public Class<? super ObjecttypeClass()
        {
            return Object.class;
        }
        @Override
        public void mergeFrom(Input inputObject ownerthrows IOException
        {
            ((Wrapperowner). = ClassSchema.readObjectFrom(inputthis,
                    ownerIdStrategy.this);
        }
        @Override
        public void writeTo(Output outputObject messagethrows IOException
        {
            ClassSchema.writeObjectTo(outputmessagethisIdStrategy.this);
        }
    };
            )
    {
        @Override
        protected void transfer(Pipe pipeInput inputOutput output)
                throws IOException
        {
            ClassSchema.transferObject(thispipeinputoutput,
                    IdStrategy.this);
        }
    };
    {
        @Override
        public String getFieldName(int number)
        {
            return PolymorphicCollectionSchema.name(number);
        }
        @Override
        public int getFieldNumber(String name)
        {
            return PolymorphicCollectionSchema.number(name);
        }
        @Override
        public boolean isInitialized(Object owner)
        {
            return true;
        }
        @Override
        public String messageFullName()
        {
            return Collection.class.getName();
        }
        @Override
        public String messageName()
        {
            return Collection.class.getSimpleName();
        }
        @Override
        public Object newMessage()
        {
            // cannot instantiate because the type is dynamic.
            throw new UnsupportedOperationException();
        }
        @Override
        public Class<? super ObjecttypeClass()
        {
            return Object.class;
        }
        @Override
        public void mergeFrom(Input inputObject ownerthrows IOException
        {
            ((Wrapperowner). = PolymorphicCollectionSchema
                    .readObjectFrom(inputthisownerIdStrategy.this);
        }
        @Override