### Question:
HashUID extends UID { public void readFields(DataInput in) throws IOException { HashUID input = HashUID.parse(in.readUTF()); this.optionalPrefix = input.optionalPrefix; this.h1 = input.h1; this.h2 = input.h2; this.time = input.time; this.extra = input.extra; } protected  HashUID(); protected  HashUID(final byte[] data, final Date time); protected  HashUID(final byte[] data, final Date time, final String... extras); protected  HashUID(final HashUID template, final String... extras); private  HashUID(final String optionalPrefix, int h1, int h2, int time, final String... extras); private  HashUID(final String optionalPrefix, int h1, int h2, int time); @SuppressWarnings({"unchecked", "rawtypes"}) static UIDBuilder<UID> builder(); @Override int compareTo(final UID uid); @Override boolean equals(Object other); String getBaseUid(); int getH0(); int getH1(); int getH2(); String getShardedPortion(); int getTime(); @Override int hashCode(); @SuppressWarnings({"unchecked", "rawtypes"}) static UIDBuilder<UID> newBuilder(final Date time); @SuppressWarnings("unchecked") static HashUID parse(String s); @SuppressWarnings("unchecked") static HashUID parse(String s, int maxExtraParts); @SuppressWarnings("unchecked") static HashUID parseBase(String s); void readFields(DataInput in); @Override String toString();  }### Answer:
@Test public void testWritable() throws IOException { UID a = new HashUID(data.getBytes(), (Date) null) {}; ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(baos); a.write(out); out.close(); UID b = new HashUID() {}; ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DataInputStream in = new DataInputStream(bais); b.readFields(in); in.close(); baos.close(); assertEquals(a, b); assertEquals(b, a); a = new HashUID(data.getBytes(), (Date) null) {}; baos = new ByteArrayOutputStream(); out = new DataOutputStream(baos); a.write(out); out.close(); b = new HashUID() {}; bais = new ByteArrayInputStream(baos.toByteArray()); in = new DataInputStream(bais); b.readFields(in); in.close(); baos.close(); assertEquals(a, b); assertEquals(b, a); a = new HashUID(data.getBytes(), null, "blabla") {}; baos = new ByteArrayOutputStream(); out = new DataOutputStream(baos); a.write(out); out.close(); b = new HashUID() {}; bais = new ByteArrayInputStream(baos.toByteArray()); in = new DataInputStream(bais); b.readFields(in); in.close(); baos.close(); assertEquals(a, b); assertEquals(b, a); }