### Question:
SnowflakeUID extends UID { @Override public void readFields(final DataInput in) throws IOException { final SnowflakeUID input = SnowflakeUID.parse(in.readUTF()); this.snowflake = input.snowflake; this.extra = input.extra; } protected  SnowflakeUID(); protected  SnowflakeUID(final BigInteger rawId, int radix, final String... extras); protected  SnowflakeUID(final SnowflakeUID template, final String... extras); @SuppressWarnings({"unchecked", "rawtypes"}) static UIDBuilder<UID> builder(); @Override int compareTo(final UID uid); @Override boolean equals(final Object other); @Override int getTime(); @Override String getBaseUid(); int getMachineId(); int getNodeId(); int getProcessId(); int getRadix(); int getSequenceId(); @Override String getShardedPortion(); int getThreadId(); long getTimestamp(); @Override int hashCode(); @SuppressWarnings("unchecked") static SnowflakeUID parse(final String s); @SuppressWarnings("unchecked") static SnowflakeUID parse(final String s, int maxExtraParts); static SnowflakeUID parse(final String s, int radix, int maxExtraParts); @SuppressWarnings("unchecked") static SnowflakeUID parseBase(final String s); @Override void readFields(final DataInput in); @Override String toString(); String toString(int radix); static final int DEFAULT_RADIX; static final long MAX_TIMESTAMP; static final int MAX_NODE_ID; static final int MAX_PROCESS_ID; static final int MAX_THREAD_ID; static final int MAX_MACHINE_ID; static final int MAX_SEQUENCE_ID; }### Answer:
@Test public void testWritable() throws IOException { UID a = builder.newId(data.getBytes(), (Date) null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(baos); a.write(out); out.close(); UID b = builder.newId(); 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 = builder.newId(data.getBytes(), (Date) null); baos = new ByteArrayOutputStream(); out = new DataOutputStream(baos); a.write(out); out.close(); b = builder.newId(); bais = new ByteArrayInputStream(baos.toByteArray()); in = new DataInputStream(bais); b.readFields(in); in.close(); baos.close(); assertEquals(a, b); assertEquals(b, a); a = builder.newId(data.getBytes(), "blabla"); baos = new ByteArrayOutputStream(); out = new DataOutputStream(baos); a.write(out); out.close(); b = new SnowflakeUID() {}; bais = new ByteArrayInputStream(baos.toByteArray()); in = new DataInputStream(bais); b.readFields(in); in.close(); baos.close(); assertEquals(a, b); assertEquals(b, a); }