Class TeamDaoList

java.lang.Object
cat.proven.teamplayer.model.persist.TeamDaoList
All Implemented Interfaces:
TeamDaoInterface

public class TeamDaoList extends Object implements TeamDaoInterface
FriendDaoList.java DAO class for Team persistence in a list. Implements singleton pattern.
Author:
Jordi and David
  • Method Details

    • getInstance

      public static TeamDaoList getInstance()
      Implements singleton pattern
      Returns:
      current instance
    • selectAll

      public List<Team> selectAll()
      Description copied from interface: TeamDaoInterface
      Selects all teams from data source
      Specified by:
      selectAll in interface TeamDaoInterface
      Returns:
      list of all teams or empty list if none if found or null in case of error
    • selectWhereId

      public Team selectWhereId(long id)
      Description copied from interface: TeamDaoInterface
      Selects a team given id
      Specified by:
      selectWhereId in interface TeamDaoInterface
      Parameters:
      id - the id from the team
      Returns:
      a team or empty in case not found, null in case of error
    • selectWhereName

      public Team selectWhereName(String name) throws ParameterNull
      Description copied from interface: TeamDaoInterface
      Selects a team given name
      Specified by:
      selectWhereName in interface TeamDaoInterface
      Parameters:
      name - the name of the team
      Returns:
      a team or empty in case not found, null in case of error
      Throws:
      ParameterNull - in case parameter passed is null a exeception will be throw
    • selectWhereCoach

      public List<Team> selectWhereCoach(String coach) throws ParameterNull
      Description copied from interface: TeamDaoInterface
      Selects teams given name of coach
      Specified by:
      selectWhereCoach in interface TeamDaoInterface
      Parameters:
      coach - the name of the coach
      Returns:
      list of teams or empty in case not found, null in case of error
      Throws:
      ParameterNull - in case parameter passed is null a exeception will be throw
    • selectWhereCategory

      public List<Team> selectWhereCategory(String category) throws ParameterNull
      Description copied from interface: TeamDaoInterface
      Selects all teams that belongs to a category
      Specified by:
      selectWhereCategory in interface TeamDaoInterface
      Parameters:
      category - the category to seach
      Returns:
      list of all teams or empty list if none if found or null in case of error
      Throws:
      ParameterNull - in case parameter passed is null a exeception will be throw
    • insert

      public int insert(Team team) throws ParameterNull, AlreadyExistsTeam
      Description copied from interface: TeamDaoInterface
      Inserts a new team
      Specified by:
      insert in interface TeamDaoInterface
      Parameters:
      team - the team to add
      Returns:
      1 if its correctly inserted or -1 in case of error
      Throws:
      ParameterNull - in case parameter passed is null a exeception will be throw
      AlreadyExistsTeam - in case of the new team introduced already exists a exeception will be throw
    • update

      public int update(Team team) throws ParameterNull
      Description copied from interface: TeamDaoInterface
      Updates the team given
      Specified by:
      update in interface TeamDaoInterface
      Parameters:
      team - the team to update their data
      Returns:
      1 if its correctly updated or -1 in case of error
      Throws:
      ParameterNull - in case parameter passed is null a exeception will be throw
    • delete

      public int delete(Team team) throws ParameterNull, TeamHavePlayers
      Description copied from interface: TeamDaoInterface
      Deletes the team given
      Specified by:
      delete in interface TeamDaoInterface
      Parameters:
      team - the team to delete
      Returns:
      1 if its correctly updated or -1 in case of error
      Throws:
      ParameterNull - in case parameter passed is null a exeception will be throw
      TeamHavePlayers - if the team to delete contains player a exeception will be throw