/***
 * 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.jpa.vehicle;

import java.util.List;

import org.nakedobjects.applib.AbstractFactoryAndRepository;
import org.nakedobjects.applib.annotation.MemberOrder;
import org.nakedobjects.applib.query.QueryDefault;

import com.pragprog.dhnako.carserv.dom.vehicle.Make;
import com.pragprog.dhnako.carserv.dom.vehicle.MakeRepository;

public class MakeRepositoryJpa 
		extends AbstractFactoryAndRepository 
		implements MakeRepository {

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

	// {{ all Makes
	@MemberOrder(sequence = "1")
	public List<Make> allMakes() {
		return allInstances(Make.class);
	}
	// }}

	// {{ findMake
	@MemberOrder(sequence = "2")
	public Make findMake(final String name) {
		return firstMatch(QueryDefault.create(Make.class, 
				"findMakeByName", "name", name));
	}
	// }}
	
}
