// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java
// public class ServiceId {
//     private final String id;
// 
//     private ServiceId(String id) {
//         this.id = id;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public static ServiceId from(String id) {
//         return new ServiceId(id);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(id);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         }
//         if (obj == null || getClass() != obj.getClass()) {
//             return false;
//         }
//         final ServiceId other = (ServiceId) obj;
//         return Objects.equals(this.id, other.id);
//     }
// 
//     @Override
//     public String toString() {
//         return id;
//     }
// }
// 
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java
// public class ServiceModel {
//     private final ServiceId serviceId;
//     private final DependencyId dependencyId;
// 
//     public ServiceModel(ServiceId serviceId, DependencyId dependencyId) {
//         this.serviceId = serviceId;
//         this.dependencyId = dependencyId;
//     }
// 
//     public ServiceId getServiceId() {
//         return serviceId;
//     }
// 
//     public DependencyId getDependencyId() {
//         return dependencyId;
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(serviceId, dependencyId);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         }
//         if (obj == null || getClass() != obj.getClass()) {
//             return false;
//         }
//         final ServiceModel other = (ServiceModel) obj;
//         return Objects.equals(this.serviceId, other.serviceId)
//                 && Objects.equals(this.dependencyId, other.dependencyId);
//     }
// }


import com.google.common.collect.ImmutableList;
import com.yammer.breakerbox.store.ServiceId;
import com.yammer.breakerbox.store.model.ServiceModel;
import org.skife.jdbi.v2.sqlobject.BindBean;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
package com.yammer.breakerbox.jdbi;


@RegisterMapper(Mappers.ServiceModelMapper.class)
public interface ServiceDB {
    @SqlQuery("select * from service where name = :service.serviceId and dependency = :service.dependencyId")
    ServiceModel find(@BindBean("service") ServiceModel service);

    @SqlUpdate("insert into service (name, dependency) values (:service.serviceId, :service.dependencyId)")
    int insert(@BindBean("service") ServiceModel service);

    @SqlUpdate("delete from service where name = :service.serviceId and dependency = :service.dependencyId")
    int delete(@BindBean("service") ServiceModel serviceModel);

    @SqlQuery("select * from service")
    ImmutableList<ServiceModel> all();

    @SqlQuery("select * from service where name = :serviceId.id")
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/ServiceId.java
// public class ServiceId {
//     private final String id;
// 
//     private ServiceId(String id) {
//         this.id = id;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public static ServiceId from(String id) {
//         return new ServiceId(id);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(id);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         }
//         if (obj == null || getClass() != obj.getClass()) {
//             return false;
//         }
//         final ServiceId other = (ServiceId) obj;
//         return Objects.equals(this.id, other.id);
//     }
// 
//     @Override
//     public String toString() {
//         return id;
//     }
// }
// 
// Path: breakerbox-store/src/main/java/com/yammer/breakerbox/store/model/ServiceModel.java
// public class ServiceModel {
//     private final ServiceId serviceId;
//     private final DependencyId dependencyId;
// 
//     public ServiceModel(ServiceId serviceId, DependencyId dependencyId) {
//         this.serviceId = serviceId;
//         this.dependencyId = dependencyId;
//     }
// 
//     public ServiceId getServiceId() {
//         return serviceId;
//     }
// 
//     public DependencyId getDependencyId() {
//         return dependencyId;
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(serviceId, dependencyId);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         }
//         if (obj == null || getClass() != obj.getClass()) {
//             return false;
//         }
//         final ServiceModel other = (ServiceModel) obj;
//         return Objects.equals(this.serviceId, other.serviceId)
//                 && Objects.equals(this.dependencyId, other.dependencyId);
//     }
// }


// Path: breakerbox-jdbi/src/main/java/com/yammer/breakerbox/jdbi/ServiceDB.java
import com.google.common.collect.ImmutableList;
import com.yammer.breakerbox.store.ServiceId;
import com.yammer.breakerbox.store.model.ServiceModel;
import org.skife.jdbi.v2.sqlobject.BindBean;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;

package com.yammer.breakerbox.jdbi;


@RegisterMapper(Mappers.ServiceModelMapper.class)
public interface ServiceDB {
    @SqlQuery("select * from service where name = :service.serviceId and dependency = :service.dependencyId")
    ServiceModel find(@BindBean("service") ServiceModel service);

    @SqlUpdate("insert into service (name, dependency) values (:service.serviceId, :service.dependencyId)")
    int insert(@BindBean("service") ServiceModel service);

    @SqlUpdate("delete from service where name = :service.serviceId and dependency = :service.dependencyId")
    int delete(@BindBean("service") ServiceModel serviceModel);

    @SqlQuery("select * from service")
    ImmutableList<ServiceModel> all();

    @SqlQuery("select * from service where name = :serviceId.id")
    ImmutableList<ServiceModel> all(@BindBean("serviceId") ServiceId serviceId);