Source:
<code>public final void writeValueRecursive(final IonReader reader) throws IOException { final IonType type = reader.getType(); final SymbolToken fieldName = reader.getFieldNameSymbol(); if (fieldName != null && !isFieldNameSet() && isInStruct()) { setFieldNameSymbol(fieldName); } final SymbolToken[] annotations = reader.getTypeAnnotationSymbols(); if (annotations.length > 0) { setTypeAnnotationSymbols(annotations); } if (reader.isNullValue()) { writeNull(type); return; } switch (type) { case BOOL: final boolean booleanValue = reader.booleanValue(); writeBool(booleanValue); break; case INT: <START> switch (reader.getIntegerType()) <END> { case INT: final int intValue = reader.intValue(); writeInt(intValue); break; case LONG: final long longValue = reader.longValue(); writeInt(longValue); break; case BIG_INTEGER: final BigInteger bigIntegerValue = reader.bigIntegerValue(); writeInt(bigIntegerValue); break; default: throw new IllegalStateException(); } break; case FLOAT: final double doubleValue = reader.doubleValue(); writeFloat(doubleValue); break; case DECIMAL: final Decimal decimalValue = reader.decimalValue(); writeDecimal(decimalValue); break; case TIMESTAMP: final Timestamp timestampValue = reader.timestampValue(); writeTimestamp(timestampValue); break; case SYMBOL: final SymbolToken symbolValue = reader.symbolValue(); writeSymbolToken(symbolValue); break; case STRING: final String stringValue = reader.stringValue(); writeString(stringValue); break; case CLOB: final byte[] clobValue = reader.newBytes(); writeClob(clobValue); break; case BLOB: final byte[] blobValue = reader.newBytes(); writeBlob(blobValue); break; case LIST: case SEXP: case STRUCT: reader.stepIn(); stepIn(type); while (reader.next() != null) { writeValue(reader); } stepOut(); reader.stepOut(); break; default: throw new IllegalStateException("Unexpected type: " + type); } }</code><technical_language>I imagine users write this structure of code size matters. provide a more streamlined approach? a visitor-style callback</technical_language>

Target:
public final void writeValueRecursive(final IonReader reader) throws IOException { final IonType type = reader.getType(); final SymbolToken fieldName = reader.getFieldNameSymbol(); if (fieldName != null && !isFieldNameSet() && isInStruct()) { setFieldNameSymbol(fieldName); } final SymbolToken[] annotations = reader.getTypeAnnotationSymbols(); if (annotations.length > 0) { setTypeAnnotationSymbols(annotations); } if (reader.isNullValue()) { writeNull(type); return; } switch (type) { case BOOL: final boolean booleanValue = reader.booleanValue(); writeBool(booleanValue); break; case INT: switch (reader.getIntegerSize()) { case INT: final int intValue = reader.intValue(); writeInt(intValue); break; case LONG: final long longValue = reader.longValue(); writeInt(longValue); break; case BIG_INTEGER: final BigInteger bigIntegerValue = reader.bigIntegerValue(); writeInt(bigIntegerValue); break; default: throw new IllegalStateException(); } break; case FLOAT: final double doubleValue = reader.doubleValue(); writeFloat(doubleValue); break; case DECIMAL: final Decimal decimalValue = reader.decimalValue(); writeDecimal(decimalValue); break; case TIMESTAMP: final Timestamp timestampValue = reader.timestampValue(); writeTimestamp(timestampValue); break; case SYMBOL: final SymbolToken symbolValue = reader.symbolValue(); writeSymbolToken(symbolValue); break; case STRING: final String stringValue = reader.stringValue(); writeString(stringValue); break; case CLOB: final byte[] clobValue = reader.newBytes(); writeClob(clobValue); break; case BLOB: final byte[] blobValue = reader.newBytes(); writeBlob(blobValue); break; case LIST: case SEXP: case STRUCT: reader.stepIn(); stepIn(type); while (reader.next() != null) { writeValue(reader); } stepOut(); reader.stepOut(); break; default: throw new IllegalStateException("Unexpected type: " + type); } }