DefineList { public DefineList deepClone() { return new DefineList(this); } DefineList(int numValues); private  DefineList(DefineList original); boolean isSet(int id); void unset(int id); void set(int id, int val); void set(int id, float val); void set(int id, boolean val); void set(int id, VarType type, Object value); void setAll(DefineList other); void clear(); boolean getBoolean(int id); float getFloat(int id); int getInt(int id); @Override int hashCode(); @Override boolean equals(Object other); DefineList deepClone(); void generateSource(StringBuilder sb, List<String> defineNames, List<VarType> defineTypes); String generateSource(List<String> defineNames, List<VarType> defineTypes); static final int MAX_DEFINES; }
@Test public void testDeepClone() { DefineList dl1 = new DefineList(NUM_DEFINES); DefineList dl2 = dl1.deepClone(); assertNotSame(dl1, dl2); assertEquals(dl1, dl2); assertEquals(dl1.hashCode(), dl2.hashCode()); dl1.set(BOOL_VAR, true); dl2 = dl1.deepClone(); assertEquals(dl1, dl2); assertEquals(dl1.hashCode(), dl2.hashCode()); dl1.set(BOOL_VAR, false); dl2 = dl1.deepClone(); assertEquals(dl1, dl2); assertEquals(dl1.hashCode(), dl2.hashCode()); dl1.set(INT_VAR, 123); assertNotEquals(dl1, dl2); assertNotEquals(dl1.hashCode(), dl2.hashCode()); dl2 = dl1.deepClone(); assertEquals(dl1, dl2); assertEquals(dl1.hashCode(), dl2.hashCode()); }