// Path: src/test/java/com/github/arteam/jdit/domain/entity/Division.java
// public enum Division {
//     PACIFIC,
//     CENTRAL,
//     METROPOLITAN,
//     ATLANTIC
// }
// 
// Path: src/test/java/com/github/arteam/jdit/domain/entity/Player.java
// public class Player {
// 
//     public final Optional<Long> id;
//     public final String firstName;
//     public final String lastName;
//     public final Date birthDate;
//     public final Optional<Integer> height;
//     public final Optional<Integer> weight;
// 
//     public Player(Optional<Long> id, String firstName, String lastName, Date birthDate,
//                   Optional<Integer> height, Optional<Integer> weight) {
//         this.id = id;
//         this.firstName = firstName;
//         this.lastName = lastName;
//         this.birthDate = birthDate;
//         this.height = height;
//         this.weight = weight;
//     }
// 
//     public Player(String firstName, String lastName, Date birthDate, int height, int weight) {
//         this(Optional.<Long>empty(), firstName, lastName, birthDate, Optional.of(height), Optional.of(weight));
//     }
// 
//     @Override
//     public String toString() {
//         return MoreObjects.toStringHelper(this)
//                 .omitNullValues()
//                 .add("id", id.orElse(null))
//                 .add("firstName", firstName)
//                 .add("lastName", lastName)
//                 .add("birthDate", birthDate)
//                 .add("height", height.orElse(null))
//                 .add("weight", weight.orElse(null))
//                 .toString();
//     }
// }
// 
// Path: src/test/java/com/github/arteam/jdit/domain/entity/Team.java
// public class Team {
// 
//     public final Optional<Long> id;
//     public final String name;
//     public final Division division;
// 
//     public Team(Optional<Long> id, String name, Division division) {
//         this.id = id;
//         this.name = name;
//         this.division = division;
//     }
// 
//     public Team(String name, Division division) {
//         this.name = name;
//         this.division = division;
//         this.id = Optional.empty();
//     }
// 
//     @Override
//     public String toString() {
//         return MoreObjects.toStringHelper(this)
//                 .add("id", id)
//                 .add("name", name)
//                 .add("division", division)
//                 .toString();
//     }
// }


import com.github.arteam.jdit.domain.entity.Division;
import com.github.arteam.jdit.domain.entity.Player;
import com.github.arteam.jdit.domain.entity.Team;
import org.jdbi.v3.sqlobject.CreateSqlObject;
import org.jdbi.v3.sqlobject.config.RegisterRowMapper;
import org.jdbi.v3.sqlobject.customizer.Bind;
import org.jdbi.v3.sqlobject.statement.GetGeneratedKeys;
import org.jdbi.v3.sqlobject.statement.SqlQuery;
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
import org.jdbi.v3.sqlobject.transaction.Transaction;
import java.util.List;
package com.github.arteam.jdit.domain;



/**
 * Date: 2/7/15
 * Time: 4:57 PM
 *
 * @author Artem Prigoda
 */
@RegisterRowMapper(PlayerSqlObject.PlayerMapper.class)
public interface TeamSqlObject {

    @CreateSqlObject
    PlayerSqlObject playerDao();

    @SqlUpdate("insert into teams(name, division) values (:name, :division)")
    @GetGeneratedKeys
    long createTeam(@Bind("name") String name, @Bind("division") Division division);

    @SqlUpdate("insert into roster(team_id, player_id) values (:team_id, :player_id)")
    void addPlayerToTeam(@Bind("team_id") long teamId, @Bind("player_id") long playerId);

    @Transaction
// Path: src/test/java/com/github/arteam/jdit/domain/entity/Division.java
// public enum Division {
//     PACIFIC,
//     CENTRAL,
//     METROPOLITAN,
//     ATLANTIC
// }
// 
// Path: src/test/java/com/github/arteam/jdit/domain/entity/Player.java
// public class Player {
// 
//     public final Optional<Long> id;
//     public final String firstName;
//     public final String lastName;
//     public final Date birthDate;
//     public final Optional<Integer> height;
//     public final Optional<Integer> weight;
// 
//     public Player(Optional<Long> id, String firstName, String lastName, Date birthDate,
//                   Optional<Integer> height, Optional<Integer> weight) {
//         this.id = id;
//         this.firstName = firstName;
//         this.lastName = lastName;
//         this.birthDate = birthDate;
//         this.height = height;
//         this.weight = weight;
//     }
// 
//     public Player(String firstName, String lastName, Date birthDate, int height, int weight) {
//         this(Optional.<Long>empty(), firstName, lastName, birthDate, Optional.of(height), Optional.of(weight));
//     }
// 
//     @Override
//     public String toString() {
//         return MoreObjects.toStringHelper(this)
//                 .omitNullValues()
//                 .add("id", id.orElse(null))
//                 .add("firstName", firstName)
//                 .add("lastName", lastName)
//                 .add("birthDate", birthDate)
//                 .add("height", height.orElse(null))
//                 .add("weight", weight.orElse(null))
//                 .toString();
//     }
// }
// 
// Path: src/test/java/com/github/arteam/jdit/domain/entity/Team.java
// public class Team {
// 
//     public final Optional<Long> id;
//     public final String name;
//     public final Division division;
// 
//     public Team(Optional<Long> id, String name, Division division) {
//         this.id = id;
//         this.name = name;
//         this.division = division;
//     }
// 
//     public Team(String name, Division division) {
//         this.name = name;
//         this.division = division;
//         this.id = Optional.empty();
//     }
// 
//     @Override
//     public String toString() {
//         return MoreObjects.toStringHelper(this)
//                 .add("id", id)
//                 .add("name", name)
//                 .add("division", division)
//                 .toString();
//     }
// }


// Path: src/test/java/com/github/arteam/jdit/domain/TeamSqlObject.java
import com.github.arteam.jdit.domain.entity.Division;
import com.github.arteam.jdit.domain.entity.Player;
import com.github.arteam.jdit.domain.entity.Team;
import org.jdbi.v3.sqlobject.CreateSqlObject;
import org.jdbi.v3.sqlobject.config.RegisterRowMapper;
import org.jdbi.v3.sqlobject.customizer.Bind;
import org.jdbi.v3.sqlobject.statement.GetGeneratedKeys;
import org.jdbi.v3.sqlobject.statement.SqlQuery;
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
import org.jdbi.v3.sqlobject.transaction.Transaction;
import java.util.List;

package com.github.arteam.jdit.domain;



/**
 * Date: 2/7/15
 * Time: 4:57 PM
 *
 * @author Artem Prigoda
 */
@RegisterRowMapper(PlayerSqlObject.PlayerMapper.class)
public interface TeamSqlObject {

    @CreateSqlObject
    PlayerSqlObject playerDao();

    @SqlUpdate("insert into teams(name, division) values (:name, :division)")
    @GetGeneratedKeys
    long createTeam(@Bind("name") String name, @Bind("division") Division division);

    @SqlUpdate("insert into roster(team_id, player_id) values (:team_id, :player_id)")
    void addPlayerToTeam(@Bind("team_id") long teamId, @Bind("player_id") long playerId);

    @Transaction
    default void addTeam(Team team, List<Player> players) {