Code example for TreeMap

Methods: containsKey, containsValue, put

0
public class SimpleItemManager implements Manager<Item> { 
	private final TreeMap<String, Item> itemList = new TreeMap<String, Item>(); 
 
	@Override 
	public boolean register(Item item) throws JPokemonError { 
		if (itemList.containsKey(item.getName())) { 
			throw new JPokemonError("A item with the name " + item.getName() + " has already been registered!"); 
		} 
		if (itemList.containsValue(item)) { 
			throw new JPokemonError("This item is already registered!"); 
		} 
		itemList.put(item.getName(), item); 
		return true; 
	} 
 
	@Override 
	public boolean isRegistered(Item item) { 
		return itemList.containsValue(item); 
	} 
 
	@Override