### Question:
SnowflakeUID extends UID { @Override public boolean equals(final Object other) { if (!(other instanceof SnowflakeUID)) { return false; } if (other == this) { return true; } return compareTo((UID) other) == 0; } 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 testEquals() { long timestamp = 1449585658444L; String uidString = builder.newId(new Date(timestamp)).toString(); UID a = SnowflakeUID.parse(uidString); UID b = SnowflakeUID.parse(uidString); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.getExtra() == null); a = SnowflakeUID.parse(uidString + ".blabla.blabla.blabla"); b = SnowflakeUID.parse(uidString + ".blabla.blabla.blabla"); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.getExtra().equals("blabla.blabla.blabla")); }
@Test public void testDifference() { long timestamp = 1449585658444L; UID a = builder.newId(data.getBytes(), new Date(timestamp)); UID b = builder.newId(data2.getBytes(), new Date(timestamp)); assertTrue(!a.equals(b)); assertTrue(!b.equals(a)); a = builder.newId(data.getBytes(), new Date(timestamp), "blabla.blabla.blabla.blabla.blabla.blabla.blabla"); b = builder.newId(data2.getBytes(), new Date(timestamp), "blabla.blabla.blabla.blabla.blabla.blabla.blabla"); assertTrue(!a.equals(b)); assertTrue(!b.equals(a)); a = builder.newId(data.getBytes(), new Date(timestamp), "blabla", "blabla", "blabla", "blabla", "blabla", "blabla", "blabla"); b = builder.newId(data2.getBytes(), new Date(timestamp), "blebla", "blabla", "blabla", "blabla", "blabla", "blabla", "blabla"); assertTrue(!a.equals(b)); assertTrue(!b.equals(a)); }