@SuppressWarnings("unchecked") public <T> T mergeObject(T value, Schema<T> schema) throws IOException { if(messageReference) { // a reference. return (T)references.get(lastRef); } lastSchema = (Schema<Object>)schema; if(value == null) value = schema.newMessage(); references.add(value); input.mergeObject(value, this); return value; }