/***
 * Excerpted from "Domain-Driven Design Using Naked Objects",
 * published by The Pragmatic Bookshelf.
 * Copyrights apply to this code. It may not be used to create training material, 
 * courses, books, articles, and the like. Contact us if you are in doubt.
 * We make no guarantees that this code is fit for any purpose. 
 * Visit http://www.pragmaticprogrammer.com/titles/dhnako for more book information.
***/
package com.pragprog.dhnako.carserv.inmemory.vehicle;

import java.util.List;

import org.nakedobjects.applib.AbstractFactoryAndRepository;
import org.nakedobjects.applib.Filter;

import com.pragprog.dhnako.carserv.dom.vehicle.VehicleType;
import com.pragprog.dhnako.carserv.dom.vehicle.VehicleTypeRepository;

public class VehicleTypeRepositoryInMemory 
		extends AbstractFactoryAndRepository 
		implements VehicleTypeRepository {

	// {{ Identification
	public String iconName() {
		return "VehicleType";
	}
	// }}

	// {{ all Types
	public List<VehicleType> allTypes() {
		return allInstances(VehicleType.class);
	}
	// }}

	// {{ find Type
	public VehicleType findType(final String fullyQualifiedClassName) {
		return firstMatch(VehicleType.class, new Filter<VehicleType>() {
			public boolean accept(VehicleType vehicleType) {
				return vehicleType.getFullyQualifiedClassName().equals(fullyQualifiedClassName);
			}
    	});
	}
	// }}
	
}
