@Override
 <C> C readNamedWriteable(Class<C> categoryClass) throws IOException {
   String name = readString();
   Writeable.Reader<? extends C> reader = namedWriteableRegistry.getReader(categoryClass, name);
   C c = reader.read(this);
   if (c == null) {
     throw new IOException(
         "Writeable.Reader ["
             + reader
             + "] returned null which is not allowed and probably means it screwed up the stream.");
   }
   return c;
 }
Esempio n. 2
0
 public <T extends Writeable> T readOptionalWriteable(Writeable.Reader<T> reader)
     throws IOException {
   if (readBoolean()) {
     T t = reader.read(this);
     if (t == null) {
       throw new IOException(
           "Writeable.Reader ["
               + reader
               + "] returned null which is not allowed and probably means it screwed up the stream.");
     }
     return t;
   } else {
     return null;
   }
 }