BosonWriter { public void writePolo(ByteBuf buffer, Object obj, int ref) { if (obj == null) { validateAndWriteType(buffer, obj); return; } Map<String, Object> data = new HashMap<>(); Class<?> klass = obj.getClass(); ReadMutator mutator = null; for (ReadMutator m : mutators) { if (m.canReadFields(klass, obj)) { mutator = m; break; } } if (mutator != null) { writePoloFieldsViaMutator(mutator, klass, obj, data); } else { writePoloFieldsViaReflection(klass, obj, data); } buffer.writeByte(POLO); buffer.writeInt(ref); writeString(buffer, klass.getName()); buffer.writeInt(data.size()); for (String key : data.keySet()) { Object value = data.get(key); writeString(buffer, key); validateAndWriteType(buffer, value); } } BosonWriter();  BosonWriter(Set<ReadMutator> mutators); ByteBuf serialize(Object msg); ByteBuf serialize(BosonMessage msg); void serializeResponse(ByteBuf buffer, BosonMessage msg); void serializeRequest(ByteBuf buffer, BosonMessage msg); void writeByte(ByteBuf buffer, byte b); void writeNull(ByteBuf buffer); void writeShort(ByteBuf buffer, short s); void writeInt(ByteBuf buffer, int i); void writeLong(ByteBuf buffer, long l); void writeFloat(ByteBuf buffer, float f); void writeDouble(ByteBuf buffer, double d); void writeBoolean(ByteBuf buffer, boolean b); void writeChar(ByteBuf buffer, char c); void writeString(ByteBuf buffer, String s); void writeEnum(ByteBuf buf, Enum param); void writeList(ByteBuf buffer, List<Object> value); void writeSet(ByteBuf buffer, Set<Object> value); void writeArray(ByteBuf buffer, Object[] value); void writeMap(ByteBuf buffer, Map<?, ?> value); void writePolo(ByteBuf buffer, Object obj, int ref); void validateAndWriteType(ByteBuf buffer, Object param); static final int MAX_RECURSION_DEPTH; static final Charset utf8; }
@Test public void testWritePolo() throws Exception { }