UniqueList extends AbstractList<T> implements List<T> { public T removeByName(final String name) { if (this.elementByName.containsKey(name)) { final T t = this.elementByName.get(name); this.elementByName.remove(name); this.list.remove(t); return t; } else { return null; } } UniqueList(); @Override void add(final int index, final T element); @Override T get(final int index); T getByName(final String name); Set<String> nameSet(); @Override T remove(final int index); @Override boolean remove(final Object o); T removeByName(final String name); @Override T set(final int index, final T element); @Override int size();  }
@Test() public final void testRemoveByName() { final UniqueList<FirstLetter> ul = new UniqueList<FirstLetter>(); final FirstLetter element = new FirstLetter("FastODS"); ul.add(element); ul.add(new FirstLetter("GastODS")); Assert.assertEquals(element, ul.removeByName("F")); }