@Override public <C extends NamedWriteable> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass, @SuppressWarnings("unused") String name) throws IOException { 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."); } assert name.equals(c.getWriteableName()) : c + " claims to have a different name [" + c.getWriteableName() + "] than it was read from [" + name + "]."; return c; } }
/** * Writes a {@link NamedWriteable} to the current stream, by first writing its name and then the object itself */ public void writeNamedWriteable(NamedWriteable namedWriteable) throws IOException { writeString(namedWriteable.getWriteableName()); namedWriteable.writeTo(this); }
private void registerPrototype(NamedWriteable<? extends T> namedWriteable) { NamedWriteable<? extends T> existingNamedWriteable = registry.get(namedWriteable.getWriteableName()); if (existingNamedWriteable != null) { throw new IllegalArgumentException("named writeable of type [" + namedWriteable.getClass().getName() + "] with name [" + namedWriteable.getWriteableName() + "] " + "is already registered by type [" + existingNamedWriteable.getClass().getName() + "] within category [" + categoryClass.getName() + "]"); } registry.put(namedWriteable.getWriteableName(), namedWriteable); }
@Override public <C extends NamedWriteable> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass, @SuppressWarnings("unused") String name) throws IOException { 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."); } assert name.equals(c.getWriteableName()) : c + " claims to have a different name [" + c.getWriteableName() + "] than it was read from [" + name + "]."; return c; } }
@Override public <C extends NamedWriteable> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass, @SuppressWarnings("unused") String name) throws IOException { 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."); } assert name.equals(c.getWriteableName()) : c + " claims to have a different name [" + c.getWriteableName() + "] than it was read from [" + name + "]."; return c; } }
/** * Writes a {@link NamedWriteable} to the current stream, by first writing its name and then the object itself */ public void writeNamedWriteable(NamedWriteable namedWriteable) throws IOException { writeString(namedWriteable.getWriteableName()); namedWriteable.writeTo(this); }
@Override public <C extends NamedWriteable> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass, @SuppressWarnings("unused") String name) throws IOException { 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."); } assert name.equals(c.getWriteableName()) : c + " claims to have a different name [" + c.getWriteableName() + "] than it was read from [" + name + "]."; return c; } }
/** * Writes a {@link NamedWriteable} to the current stream, by first writing its name and then the object itself */ public void writeNamedWriteable(NamedWriteable namedWriteable) throws IOException { writeString(namedWriteable.getWriteableName()); namedWriteable.writeTo(this); }
/** * Writes a {@link NamedWriteable} to the current stream, by first writing its name and then the object itself */ public void writeNamedWriteable(NamedWriteable namedWriteable) throws IOException { writeString(namedWriteable.getWriteableName()); namedWriteable.writeTo(this); }
/** * Writes a {@link NamedWriteable} to the current stream, by first writing its name and then the object itself */ void writeNamedWriteable(NamedWriteable namedWriteable) throws IOException { writeString(namedWriteable.getWriteableName()); namedWriteable.writeTo(this); }