@Test(expected = IllegalArgumentException.class) public void getKeyIndex_throwsExceptionForNonExistantKey() { ImapList list = buildSampleList(); list.getKeyIndex("nonexistent"); }
public int getKeyIndex(String key) { for (int i = 0, count = size() - 1; i < count; i++) { if (ImapResponseParser.equalsIgnoreCase(get(i), key)) { return i; } } throw new IllegalArgumentException("getKeyIndex() only works for keys that are in the collection."); }
ImapList extends ArrayList<Object> { public int getKeyIndex(String key) { for (int i = 0, count = size() - 1; i < count; i++) { if (ImapResponseParser.equalsIgnoreCase(get(i), key)) { return i; } } throw new IllegalArgumentException("getKeyIndex() only works for keys that are in the collection."); } }
ImapList extends ArrayList<Object> { public int getKeyIndex(String key) { for (int i = 0, count = size() - 1; i < count; i++) { if (ImapResponseParser.equalsIgnoreCase(get(i), key)) { return i; } } throw new IllegalArgumentException("getKeyIndex() only works for keys that are in the collection."); }  }
ImapList extends ArrayList<Object> { public int getKeyIndex(String key) { for (int i = 0, count = size() - 1; i < count; i++) { if (ImapResponseParser.equalsIgnoreCase(get(i), key)) { return i; } } throw new IllegalArgumentException("getKeyIndex() only works for keys that are in the collection."); }  ImapList getList(int index); boolean isList(int index); Object getObject(int index); String getString(int index); boolean isString(int index); long getLong(int index); int getNumber(int index); Date getDate(int index); Date getKeyedDate(String key); Object getKeyedValue(String key); ImapList getKeyedList(String key); String getKeyedString(String key); int getKeyedNumber(String key); boolean containsKey(String key); int getKeyIndex(String key); }
ImapList extends ArrayList<Object> { public int getKeyIndex(String key) { for (int i = 0, count = size() - 1; i < count; i++) { if (ImapResponseParser.equalsIgnoreCase(get(i), key)) { return i; } } throw new IllegalArgumentException("getKeyIndex() only works for keys that are in the collection."); }  ImapList getList(int index); boolean isList(int index); Object getObject(int index); String getString(int index); boolean isString(int index); long getLong(int index); int getNumber(int index); Date getDate(int index); Date getKeyedDate(String key); Object getKeyedValue(String key); ImapList getKeyedList(String key); String getKeyedString(String key); int getKeyedNumber(String key); boolean containsKey(String key); int getKeyIndex(String key);  }