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

import java.util.List;

import org.nakedobjects.applib.Filter;
import org.nakedobjects.applib.annotation.MemberOrder;

import com.pragprog.dhnako.carserv.dom.service.ServiceableVehicle;
import com.pragprog.dhnako.carserv.dom.service.ServiceableVehicleRepository;
import com.pragprog.dhnako.carserv.dom.vehicle.Model;
import com.pragprog.dhnako.carserv.inmemory.vehicle.VehicleRepositoryInMemory;

public class ServiceableVehicleRepositoryInMemory extends VehicleRepositoryInMemory implements ServiceableVehicleRepository {


	// {{ find Vehicles Without Recent Service
	@MemberOrder(sequence = "2")
    public List<ServiceableVehicle> findVehiclesWithoutRecentService(
    		final Model model) {
        return allMatches(ServiceableVehicle.class, new Filter<ServiceableVehicle>() {
            public boolean accept(ServiceableVehicle vehicle) {
                if (vehicle.getModel() != model) return false;
                return vehicle.isServiceOverdue();
            }});
    }
	// }}




}
