@Test public void testGetKey() { KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); assertEquals("Key 1", ko1.getKey(0)); assertEquals("Key 2", ko1.getKey(1)); assertEquals("Key 3", ko1.getKey(2)); try { ko1.getKey(-1); fail("Should have thrown IndexOutOfBoundsException on negative key"); } catch (IndexOutOfBoundsException e) { assertEquals("-1", e.getMessage()); } try { ko1.getKey(3); fail("Should have thrown IndexOutOfBoundsException on key out of range"); } catch (IndexOutOfBoundsException e) { assertEquals("Index: 3, Size: 3", e.getMessage()); } }
public Comparable getKey(int index) { Comparable result = null; KeyedObject item = this.data.get(index); if (item != null) { result = item.getKey(); } return result; }
KeyedObjects implements Cloneable, PublicCloneable, Serializable { public Comparable getKey(int index) { Comparable result = null; KeyedObject item = this.data.get(index); if (item != null) { result = item.getKey(); } return result; } }
KeyedObjects implements Cloneable, PublicCloneable, Serializable { public Comparable getKey(int index) { Comparable result = null; KeyedObject item = this.data.get(index); if (item != null) { result = item.getKey(); } return result; } KeyedObjects(); }
KeyedObjects implements Cloneable, PublicCloneable, Serializable { public Comparable getKey(int index) { Comparable result = null; KeyedObject item = this.data.get(index); if (item != null) { result = item.getKey(); } return result; } KeyedObjects(); int getItemCount(); Object getObject(int item); Comparable getKey(int index); int getIndex(Comparable key); List<Comparable> getKeys(); Object getObject(Comparable key); void addObject(Comparable key, Object object); void setObject(Comparable key, Object object); void insertValue(int position, Comparable key, Object value); void removeValue(int index); void removeValue(Comparable key); void clear(); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode(); }
KeyedObjects implements Cloneable, PublicCloneable, Serializable { public Comparable getKey(int index) { Comparable result = null; KeyedObject item = this.data.get(index); if (item != null) { result = item.getKey(); } return result; } KeyedObjects(); int getItemCount(); Object getObject(int item); Comparable getKey(int index); int getIndex(Comparable key); List<Comparable> getKeys(); Object getObject(Comparable key); void addObject(Comparable key, Object object); void setObject(Comparable key, Object object); void insertValue(int position, Comparable key, Object value); void removeValue(int index); void removeValue(Comparable key); void clear(); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode();  }