@Test public void testGetGroup() { KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); assertEquals("Default Group", m1.getGroup("K1")); m1.mapKeyToGroup("K1", "G1"); assertEquals("G1", m1.getGroup("K1")); m1.mapKeyToGroup("K1", "G2"); assertEquals("G2", m1.getGroup("K1")); m1.mapKeyToGroup("K1", null); assertEquals("Default Group", m1.getGroup("K1")); try { m1.getGroup(null); fail("Should have thrown IllegalArgumentException on null key"); } catch (IllegalArgumentException e) { assertEquals("Null 'key' argument.", e.getMessage()); } }
public Comparable getGroup(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Comparable result = this.defaultGroup; Comparable group = this.keyToGroupMap.get(key); if (group != null) { result = group; } return result; }
KeyToGroupMap implements Cloneable, PublicCloneable, Serializable { public Comparable getGroup(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Comparable result = this.defaultGroup; Comparable group = this.keyToGroupMap.get(key); if (group != null) { result = group; } return result; } }
KeyToGroupMap implements Cloneable, PublicCloneable, Serializable { public Comparable getGroup(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Comparable result = this.defaultGroup; Comparable group = this.keyToGroupMap.get(key); if (group != null) { result = group; } return result; } KeyToGroupMap();  KeyToGroupMap(Comparable defaultGroup); }
KeyToGroupMap implements Cloneable, PublicCloneable, Serializable { public Comparable getGroup(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Comparable result = this.defaultGroup; Comparable group = this.keyToGroupMap.get(key); if (group != null) { result = group; } return result; } KeyToGroupMap();  KeyToGroupMap(Comparable defaultGroup); int getGroupCount(); List<Comparable> getGroups(); int getGroupIndex(Comparable group); Comparable getGroup(Comparable key); void mapKeyToGroup(Comparable key, Comparable group); int getKeyCount(Comparable group); @Override boolean equals(Object obj); @Override Object clone(); }
KeyToGroupMap implements Cloneable, PublicCloneable, Serializable { public Comparable getGroup(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Comparable result = this.defaultGroup; Comparable group = this.keyToGroupMap.get(key); if (group != null) { result = group; } return result; } KeyToGroupMap();  KeyToGroupMap(Comparable defaultGroup); int getGroupCount(); List<Comparable> getGroups(); int getGroupIndex(Comparable group); Comparable getGroup(Comparable key); void mapKeyToGroup(Comparable key, Comparable group); int getKeyCount(Comparable group); @Override boolean equals(Object obj); @Override Object clone();  }