Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   //========================================================================
   //Copyright 2007-2011 David Yu dyuproject@gmail.com
   //------------------------------------------------------------------------
   //Licensed under the Apache License, Version 2.0 (the "License");
   //you may not use this file except in compliance with the License.
   //You may obtain a copy of the License at 
   //http://www.apache.org/licenses/LICENSE-2.0
   //Unless required by applicable law or agreed to in writing, software
   //distributed under the License is distributed on an "AS IS" BASIS,
  //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  //See the License for the specific language governing permissions and
  //limitations under the License.
  //========================================================================
  
  package io.protostuff.runtime;
  
  import java.util.EnumMap;
  import java.util.Map;
  
  import io.protostuff.Tag;
Static utility for creating runtime java.util.Map fields.

Author(s):
David Yu
Created:
Jan 21, 2011
  
  final class RuntimeMapFieldFactory
  {
  
      private RuntimeMapFieldFactory()
      {
      }
  
      /*
       * private static final DerivativeSchema POLYMORPHIC_MAP_VALUE_SCHEMA = new DerivativeSchema() {
       * 
       * @SuppressWarnings("unchecked") protected void doMergeFrom(Input input, Schema<Object> derivedSchema, Object
       * owner) throws IOException { final Object value = derivedSchema.newMessage();
       * 
       * // the owner will always be the MapWrapper ((MapWrapper<Object,Object>)owner).setValue(value);
       * 
       * if(input instanceof GraphInput) { // update the actual reference. ((GraphInput)input).updateLast(value, owner); }
       * 
       * derivedSchema.mergeFrom(input, value); } };
       */
  
      /*
       * private static final ObjectSchema OBJECT_MAP_VALUE_SCHEMA = new ObjectSchema() {
       * 
       * @SuppressWarnings("unchecked") protected void setValue(Object value, Object owner) { // the owner will always be
       * the MapWrapper ((MapWrapper<Object,Object>)owner).setValue(value); } };
       */
  
      private static <T> Field<T> createMapInlineKEnumV(int numberString name,
              final java.lang.reflect.Field fMessageFactory messageFactory,
              final Delegate<ObjectinlineKfinal Class<ObjectclazzV,
              IdStrategy strategy)
      {
          final EnumIO<?> eioV = strategy.getEnumIO(clazzV);
  
          return new RuntimeMapField<T, ObjectEnum<?>>(.,
                  numbernamef.getAnnotation(Tag.class), messageFactory)
          {
              {
                  f.setAccessible(true);
              }
  
              @Override
              @SuppressWarnings("unchecked")
              protected void mergeFrom(Input input, T messagethrows IOException
              {
                  try
                  {
                      f.set(messageinput.mergeObject(
                              (Map<ObjectEnum<?>>) f.get(message), ));
                  }
                  catch (IllegalArgumentException | IllegalAccessException e)
                  {
                      throw new RuntimeException(e);
                  }
              }
  
              @Override
              @SuppressWarnings("unchecked")
              protected void writeTo(Output output, T messagethrows IOException
             {
                 final Map<ObjectEnum<?>> existing;
                 try
                 {
                     existing = (Map<ObjectEnum<?>>) f.get(message);
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
 
                 if (existing != null)
                     output.writeObject(existingfalse);
             }
 
             @Override
             protected void transfer(Pipe pipeInput inputOutput output,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(pipe.repeated);
             }
 
             @Override
             protected Object kFrom(Input input,
                     MapWrapper<ObjectEnum<?>> wrapperthrows IOException
             {
                 return inlineK.readFrom(input);
             }
 
             @Override
             protected void kTo(Output outputint fieldNumberObject key,
                     boolean repeatedthrows IOException
             {
                 inlineK.writeTo(outputfieldNumberkeyrepeated);
             }
 
             @Override
             protected void kTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 inlineK.transfer(pipeinputoutputnumberrepeated);
             }
 
             @Override
             protected void vPutFrom(Input input,
                     MapWrapper<ObjectEnum<?>> wrapperObject key)
                     throws IOException
             {
                 wrapper.put(keyeioV.readFrom(input));
             }
 
             @Override
             protected void vTo(Output outputint fieldNumberEnum<?> val,
                     boolean repeatedthrows IOException
             {
                 eioV.writeTo(outputfieldNumberrepeatedval);
             }
 
             @Override
             protected void vTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 EnumIO.transfer(pipeinputoutputnumberrepeated);
             }
         };
     }
 
     private static <T> Field<T> createMapInlineKInlineV(int number,
             String namefinal java.lang.reflect.Field f,
             MessageFactory messageFactoryfinal Delegate<ObjectinlineK,
             final Delegate<ObjectinlineV)
     {
         return new RuntimeMapField<T, ObjectObject>(.,
                 numbernamef.getAnnotation(Tag.class), messageFactory)
         {
             {
                 f.setAccessible(true);
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void mergeFrom(Input input, T messagethrows IOException
             {
                 try
                 {
                     f.set(messageinput.mergeObject(
                             (Map<ObjectObject>) f.get(message), ));
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void writeTo(Output output, T messagethrows IOException
             {
                 final Map<ObjectObjectexisting;
                 try
                 {
                     existing = (Map<ObjectObject>) f.get(message);
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
 
                 if (existing != null)
                     output.writeObject(existingfalse);
             }
 
             @Override
             protected void transfer(Pipe pipeInput inputOutput output,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(pipe.repeated);
             }
 
             @Override
             protected Object kFrom(Input input,
                     MapWrapper<ObjectObjectwrapperthrows IOException
             {
                 return inlineK.readFrom(input);
             }
 
             @Override
             protected void kTo(Output outputint fieldNumberObject key,
                     boolean repeatedthrows IOException
             {
                 inlineK.writeTo(outputfieldNumberkeyrepeated);
             }
 
             @Override
             protected void kTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 inlineK.transfer(pipeinputoutputnumberrepeated);
             }
 
             @Override
             protected void vPutFrom(Input input,
                     MapWrapper<ObjectObjectwrapperObject key)
                     throws IOException
             {
                 wrapper.put(keyinlineV.readFrom(input));
             }
 
             @Override
             protected void vTo(Output outputint fieldNumberObject val,
                     boolean repeatedthrows IOException
             {
                 inlineV.writeTo(outputfieldNumbervalrepeated);
             }
 
             @Override
             protected void vTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 inlineV.transfer(pipeinputoutputnumberrepeated);
             }
         };
     }
 
     private static <T> Field<T> createMapInlineKPojoV(int numberString name,
             final java.lang.reflect.Field fMessageFactory messageFactory,
             final Delegate<ObjectinlineKfinal Class<ObjectclazzV,
             IdStrategy strategy)
     {
         final HasSchema<ObjectschemaV = strategy.getSchemaWrapper(clazzV,
                 true);
 
         return new RuntimeMapField<T, ObjectObject>(.,
                 numbernamef.getAnnotation(Tag.class), messageFactory)
         {
             {
                 f.setAccessible(true);
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void mergeFrom(Input input, T messagethrows IOException
             {
                 try
                 {
                     f.set(messageinput.mergeObject(
                             (Map<ObjectObject>) f.get(message), ));
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void writeTo(Output output, T messagethrows IOException
             {
                 final Map<ObjectObjectexisting;
                 try
                 {
                     existing = (Map<ObjectObject>) f.get(message);
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
 
                 if (existing != null)
                     output.writeObject(existingfalse);
             }
 
             @Override
             protected void transfer(Pipe pipeInput inputOutput output,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(pipe.repeated);
             }
 
             @Override
             protected Object kFrom(Input input,
                     MapWrapper<ObjectObjectwrapperthrows IOException
             {
                 return inlineK.readFrom(input);
             }
 
             @Override
             protected void kTo(Output outputint fieldNumberObject key,
                     boolean repeatedthrows IOException
             {
                 inlineK.writeTo(outputfieldNumberkeyrepeated);
             }
 
             @Override
             protected void kTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 inlineK.transfer(pipeinputoutputnumberrepeated);
             }
 
             @Override
             protected void vPutFrom(Input input,
                     MapWrapper<ObjectObjectwrapperObject key)
                     throws IOException
             {
                 wrapper.put(keyinput.mergeObject(nullschemaV.getSchema()));
             }
 
             @Override
             protected void vTo(Output outputint fieldNumberObject val,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(fieldNumbervalschemaV.getSchema(),
                         repeated);
             }
 
             @Override
             protected void vTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 output.writeObject(numberpipeschemaV.getPipeSchema(),
                         repeated);
             }
         };
     }
 
     private static <T> Field<T> createMapInlineKPolymorphicV(int number,
             String namefinal java.lang.reflect.Field f,
             MessageFactory messageFactoryfinal Delegate<ObjectinlineK,
             final Class<ObjectclazzVfinal IdStrategy strategy)
     {
         return new RuntimeMapField<T, ObjectObject>(.,
                 numbernamef.getAnnotation(Tag.class), messageFactory)
         {
 
             {
                 f.setAccessible(true);
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void mergeFrom(Input input, T messagethrows IOException
             {
                 try
                 {
                     f.set(messageinput.mergeObject(
                             (Map<ObjectObject>) f.get(message), ));
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void writeTo(Output output, T messagethrows IOException
             {
                 final Map<ObjectObjectexisting;
                 try
                 {
                     existing = (Map<ObjectObject>) f.get(message);
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
 
                 if (existing != null)
                     output.writeObject(existingfalse);
             }
 
             @Override
             protected void transfer(Pipe pipeInput inputOutput output,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(pipe.repeated);
             }
 
             @Override
             protected Object kFrom(Input input,
                     MapWrapper<ObjectObjectwrapperthrows IOException
             {
                 return inlineK.readFrom(input);
             }
 
             @Override
             protected void kTo(Output outputint fieldNumberObject key,
                     boolean repeatedthrows IOException
             {
                 inlineK.writeTo(outputfieldNumberkeyrepeated);
             }
 
             @Override
             protected void kTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 inlineK.transfer(pipeinputoutputnumberrepeated);
             }
 
             @Override
             protected void vPutFrom(Input input,
                     MapWrapper<ObjectObjectwrapperObject key)
                     throws IOException
             {
                 final Object value = input.mergeObject(wrapper,
                         strategy.POLYMORPHIC_POJO_ELEMENT_SCHEMA);
                 if (value != wrapper)
                 {
                     // referenced.
                     // An entry would never have a cyclic reference.
                     ((GraphInputinput).updateLast(valuewrapper);
 
                     wrapper.put(keyvalue);
                     return;
                 }
 
                 if (key != null)
                 {
                     // we can already add the entry.
                     wrapper.put(keywrapper.setValue(null));
                 }
             }
 
             @Override
             protected void vTo(Output outputint fieldNumberObject val,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(fieldNumberval,
                         strategy.POLYMORPHIC_POJO_ELEMENT_SCHEMArepeated);
             }
 
             @Override
             protected void vTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 output.writeObject(numberpipe,
                         strategy.POLYMORPHIC_POJO_ELEMENT_SCHEMA.pipeSchema,
                         repeated);
             }
         };
     }
 
     private static <T> Field<T> createMapInlineKObjectV(int number,
             String namefinal java.lang.reflect.Field f,
             MessageFactory messageFactoryfinal Delegate<ObjectinlineK,
             final Schema<ObjectvalueSchema,
             final Pipe.Schema<ObjectvaluePipeSchemafinal IdStrategy strategy)
     {
         return new RuntimeMapField<T, ObjectObject>(.,
                 numbernamef.getAnnotation(Tag.class), messageFactory)
         {
 
             {
                 f.setAccessible(true);
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void mergeFrom(Input input, T messagethrows IOException
             {
                 try
                 {
                     f.set(messageinput.mergeObject(
                             (Map<ObjectObject>) f.get(message), ));
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void writeTo(Output output, T messagethrows IOException
             {
                 final Map<ObjectObjectexisting;
                 try
                 {
                     existing = (Map<ObjectObject>) f.get(message);
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
 
                 if (existing != null)
                     output.writeObject(existingfalse);
             }
 
             @Override
             protected void transfer(Pipe pipeInput inputOutput output,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(pipe.repeated);
             }
 
             @Override
             protected Object kFrom(Input input,
                     MapWrapper<ObjectObjectwrapperthrows IOException
             {
                 return inlineK.readFrom(input);
             }
 
             @Override
             protected void kTo(Output outputint fieldNumberObject key,
                     boolean repeatedthrows IOException
             {
                 inlineK.writeTo(outputfieldNumberkeyrepeated);
             }
 
             @Override
             protected void kTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 inlineK.transfer(pipeinputoutputnumberrepeated);
             }
 
             @Override
             protected void vPutFrom(Input input,
                     MapWrapper<ObjectObjectwrapperObject key)
                     throws IOException
             {
                 final Object value = input.mergeObject(wrappervalueSchema);
                 if (value != wrapper)
                 {
                     // referenced.
                     // An entry would never have a cyclic reference.
                     ((GraphInputinput).updateLast(valuewrapper);
 
                     wrapper.put(keyvalue);
                     return;
                 }
 
                 if (key != null)
                 {
                     // we can already add the entry.
                     wrapper.put(keywrapper.setValue(null));
                 }
             }
 
             @Override
             protected void vTo(Output outputint fieldNumberObject val,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(fieldNumbervalvalueSchemarepeated);
             }
 
             @Override
             protected void vTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 output.writeObject(numberpipevaluePipeSchemarepeated);
             }
         };
     }
 
     private static <T> Field<T> createMapEnumKEnumV(int numberString name,
             final java.lang.reflect.Field fMessageFactory messageFactory,
             final Class<ObjectclazzKfinal Class<ObjectclazzV,
             IdStrategy strategy)
     {
         final EnumIO<?> eioK = strategy.getEnumIO(clazzK);
         final EnumIO<?> eioV = strategy.getEnumIO(clazzV);
 
         return new RuntimeMapField<T, Enum<?>, Enum<?>>(.,
                 numbernamef.getAnnotation(Tag.class), messageFactory)
         {
             {
                 f.setAccessible(true);
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void mergeFrom(Input input, T messagethrows IOException
             {
                 try
                 {
                     f.set(messageinput.mergeObject(
                             (Map<Enum<?>, Enum<?>>) f.get(message), ));
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void writeTo(Output output, T messagethrows IOException
             {
                 final Map<Enum<?>, Enum<?>> existing;
                 try
                 {
                     existing = (Map<Enum<?>, Enum<?>>) f.get(message);
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
 
                 if (existing != null)
                     output.writeObject(existingfalse);
             }
 
             @Override
             protected void transfer(Pipe pipeInput inputOutput output,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(pipe.repeated);
             }
 
             @Override
             protected Enum<?> kFrom(Input input,
                     MapWrapper<Enum<?>, Enum<?>> wrapperthrows IOException
             {
                 return eioK.readFrom(input);
             }
 
             @Override
             protected void kTo(Output outputint fieldNumberEnum<?> key,
                     boolean repeatedthrows IOException
             {
                 eioK.writeTo(outputfieldNumberrepeatedkey);
             }
 
             @Override
             protected void kTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 EnumIO.transfer(pipeinputoutputnumberrepeated);
             }
 
             @Override
             protected void vPutFrom(Input input,
                     MapWrapper<Enum<?>, Enum<?>> wrapperEnum<?> key)
                     throws IOException
             {
                 wrapper.put(keyeioV.readFrom(input));
             }
 
             @Override
             protected void vTo(Output outputint fieldNumberEnum<?> val,
                     boolean repeatedthrows IOException
             {
                 eioV.writeTo(outputfieldNumberrepeatedval);
             }
 
             @Override
             protected void vTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 EnumIO.transfer(pipeinputoutputnumberrepeated);
             }
         };
     }
 
     private static <T> Field<T> createMapEnumKInlineV(int numberString name,
             final java.lang.reflect.Field fMessageFactory messageFactory,
             final Class<ObjectclazzKfinal Delegate<ObjectinlineV,
             IdStrategy strategy)
     {
         final EnumIO<?> eioK = strategy.getEnumIO(clazzK);
 
         return new RuntimeMapField<T, Enum<?>, Object>(.,
                 numbernamef.getAnnotation(Tag.class), messageFactory)
         {
             {
                 f.setAccessible(true);
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void mergeFrom(Input input, T messagethrows IOException
             {
                 try
                 {
                     f.set(messageinput.mergeObject(
                             (Map<Enum<?>, Object>) f.get(message), ));
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void writeTo(Output output, T messagethrows IOException
             {
                 final Map<Enum<?>, Objectexisting;
                 try
                 {
                     existing = (Map<Enum<?>, Object>) f.get(message);
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
 
                 if (existing != null)
                     output.writeObject(existingfalse);
             }
 
             @Override
             protected void transfer(Pipe pipeInput inputOutput output,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(pipe.repeated);
             }
 
             @Override
             protected Enum<?> kFrom(Input input,
                     MapWrapper<Enum<?>, Objectwrapperthrows IOException
             {
                 return eioK.readFrom(input);
             }
 
             @Override
             protected void kTo(Output outputint fieldNumberEnum<?> key,
                     boolean repeatedthrows IOException
             {
                 eioK.writeTo(outputfieldNumberrepeatedkey);
             }
 
             @Override
             protected void kTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 EnumIO.transfer(pipeinputoutputnumberrepeated);
             }
 
             @Override
             protected void vPutFrom(Input input,
                     MapWrapper<Enum<?>, ObjectwrapperEnum<?> key)
                     throws IOException
             {
                 wrapper.put(keyinlineV.readFrom(input));
             }
 
             @Override
             protected void vTo(Output outputint fieldNumberObject val,
                     boolean repeatedthrows IOException
             {
                 inlineV.writeTo(outputfieldNumbervalrepeated);
             }
 
             @Override
             protected void vTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 inlineV.transfer(pipeinputoutputnumberrepeated);
             }
         };
     }
 
     private static <T> Field<T> createMapEnumKPojoV(int numberString name,
             final java.lang.reflect.Field fMessageFactory messageFactory,
             final Class<ObjectclazzKfinal Class<ObjectclazzV,
             IdStrategy strategy)
     {
         final EnumIO<?> eioK = strategy.getEnumIO(clazzK);
         final HasSchema<ObjectschemaV = strategy.getSchemaWrapper(clazzV,
                 true);
 
         return new RuntimeMapField<T, Enum<?>, Object>(.,
                 numbernamef.getAnnotation(Tag.class), messageFactory)
         {
             {
                 f.setAccessible(true);
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void mergeFrom(Input input, T messagethrows IOException
             {
                 try
                 {
                     f.set(messageinput.mergeObject(
                             (Map<Enum<?>, Object>) f.get(message), ));
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void writeTo(Output output, T messagethrows IOException
             {
                 final Map<Enum<?>, Objectexisting;
                 try
                 {
                     existing = (Map<Enum<?>, Object>) f.get(message);
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
 
                 if (existing != null)
                     output.writeObject(existingfalse);
             }
 
             @Override
             protected void transfer(Pipe pipeInput inputOutput output,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(pipe.repeated);
             }
 
             @Override
             protected Enum<?> kFrom(Input input,
                     MapWrapper<Enum<?>, Objectwrapperthrows IOException
             {
                 return eioK.readFrom(input);
             }
 
             @Override
             protected void kTo(Output outputint fieldNumberEnum<?> key,
                     boolean repeatedthrows IOException
             {
                 eioK.writeTo(outputfieldNumberrepeatedkey);
             }
 
             @Override
             protected void kTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 EnumIO.transfer(pipeinputoutputnumberrepeated);
             }
 
             @Override
             protected void vPutFrom(Input input,
                     MapWrapper<Enum<?>, ObjectwrapperEnum<?> key)
                     throws IOException
             {
                 wrapper.put(keyinput.mergeObject(nullschemaV.getSchema()));
             }
 
             @Override
             protected void vTo(Output outputint fieldNumberObject val,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(fieldNumbervalschemaV.getSchema(),
                         repeated);
             }
 
             @Override
             protected void vTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 output.writeObject(numberpipeschemaV.getPipeSchema(),
                         repeated);
             }
         };
     }
 
     private static <T> Field<T> createMapEnumKPolymorphicV(int number,
             String namefinal java.lang.reflect.Field f,
             MessageFactory messageFactoryfinal Class<ObjectclazzK,
             final Class<ObjectclazzVfinal IdStrategy strategy)
     {
         final EnumIO<?> eioK = strategy.getEnumIO(clazzK);
 
         return new RuntimeMapField<T, Enum<?>, Object>(.,
                 numbernamef.getAnnotation(Tag.class), messageFactory)
         {
 
             {
                 f.setAccessible(true);
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void mergeFrom(Input input, T messagethrows IOException
             {
                 try
                 {
                     f.set(messageinput.mergeObject(
                             (Map<Enum<?>, Object>) f.get(message), ));
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
             }
 
             @Override
             @SuppressWarnings("unchecked")
             protected void writeTo(Output output, T messagethrows IOException
             {
                 final Map<Enum<?>, Objectexisting;
                 try
                 {
                     existing = (Map<Enum<?>, Object>) f.get(message);
                 }
                 catch (IllegalArgumentException | IllegalAccessException e)
                 {
                     throw new RuntimeException(e);
                 }
 
                 if (existing != null)
                     output.writeObject(existingfalse);
             }
 
             @Override
             protected void transfer(Pipe pipeInput inputOutput output,
                     boolean repeatedthrows IOException
             {
                 output.writeObject(pipe.repeated);
             }
 
             @Override
             protected Enum<?> kFrom(Input input,
                     MapWrapper<Enum<?>, Objectwrapperthrows IOException
             {
                 return eioK.readFrom(input);
             }
 
             @Override
             protected void kTo(Output outputint fieldNumberEnum<?> key,
                     boolean repeatedthrows IOException
             {
                 eioK.writeTo(outputfieldNumberrepeatedkey);
             }
 
             @Override
             protected void kTransfer(Pipe pipeInput inputOutput output,
                     int numberboolean repeatedthrows IOException
             {
                 EnumIO.transfer(pipeinputoutputnumberrepeated);
             }
 
             @Override
             protected void vPutFrom(Input input,
                     MapWrapper<Enum<?>, ObjectwrapperEnum<?> key)
                     throws IOException
             {
                 final Object value = input.mergeObject(wrapper,
                         strategy.POLYMORPHIC_POJO_ELEMENT_SCHEMA);
                 if (value != wrapper)
                 {
                     // referenced.
                     // An entry would never have a cyclic reference.
                     ((GraphInputinput).updateLast(valuewrapper);
 
                     wrapper.put(keyvalue);
                     return;
                 }
 
                 if (key != null)
                 {
                     // we can already add the entry.
                     wrapper.put(keywrapper.setValue(null));
                 }
             }
 
             @Override
            protected void vTo(Output outputint fieldNumberObject val,
                    boolean repeatedthrows IOException
            {
                output.writeObject(