public void writeReference(Reference reference) throws IOException {
        if (reference instanceof StringReference) {
            writeQuotedString((StringReference) reference);
        } else if (reference instanceof TypeReference) {
            writeType((TypeReference) reference);
        } else if (reference instanceof FieldReference) {
            writeFieldDescriptor((FieldReference) reference);
        } else if (reference instanceof MethodReference) {
            writeMethodDescriptor((MethodReference) reference);
        } else if (reference instanceof MethodProtoReference) {
            writeMethodProtoDescriptor((MethodProtoReference) reference);
        } else if (reference instanceof MethodHandleReference) {
            writeMethodHandle((MethodHandleReference) reference);
        } else if (reference instanceof CallSiteReference) {
            writeCallSite((CallSiteReference) reference);
        } else {
            throw new IllegalArgumentException(String.format("Not a known reference type: %s", reference.getClass()));
        }
    }
@Test
    public void testWriteReference_string() throws IOException {
        DexFormattedWriter writer = new DexFormattedWriter(output);

        writer.writeReference(new ImmutableStringReference("string value"));

        Assert.assertEquals(
                "\"string value\"",
                output.toString());
    }