private static MessageHistory readHistoryFromBytes(final Wire wire, MessageHistory history) { final Bytes<?> bytes = wire.bytes(); if (MESSAGE_HISTORY_METHOD_ID != wire.readEventNumber()) return null; ((BytesMarshallable) history).readMarshallable(bytes); return history; }
@Override public Object[] decode(Object[] lastObjects, BytesIn in) { for (Object lastObject : lastObjects) ((BytesMarshallable) lastObject).readMarshallable(in); return lastObjects; } };
@Override protected void setValue(Object o, BytesIn read) throws IllegalAccessException, IORuntimeException { @NotNull BytesMarshallable o2 = (BytesMarshallable) field.get(o); if (!field.getType().isInstance(o2)) field.set(o, o2 = (BytesMarshallable) ObjectUtils.newInstance((Class) field.getType())); o2.readMarshallable(read); } }
@NotNull @Override public T read(Bytes in, @Nullable T using) { if (using == null) using = createInstance(); using.readMarshallable(in); return using; } }
private static MessageHistory readHistoryFromBytes(final Wire wire, MessageHistory history) { final Bytes<?> bytes = wire.bytes(); if (MESSAGE_HISTORY_METHOD_ID != wire.readEventNumber()) return null; ((BytesMarshallable) history).readMarshallable(bytes); return history; }
@Override public T getUsing(@Nullable T using) { if (using == null) using = createInstance(); initBytes(); using.readMarshallable(bytes); bytes.readPosition(0); return using; }
default <T> T readObject(Class<T> componentType) { if (BytesMarshallable.class.isAssignableFrom(componentType)) { BytesMarshallable bm = (BytesMarshallable) ObjectUtils.newInstance(componentType); bm.readMarshallable(this); return (T) bm; } if (Enum.class.isAssignableFrom(componentType)) { return (T) readEnum((Class) componentType); } switch (componentType.getName()) { case "java.lang.String": return (T) readUtf8(); case "java.lang.Double": return (T) (Double) readDouble(); case "java.lang.Long": return (T) (Long) readLong(); case "java.lang.Integer": return (T) (Integer) readInt(); default: throw new UnsupportedOperationException("Unsupported " + componentType); } } }