Class WettAngebot

java.lang.Object
net.bjmsw.hda.vs.model.db.WettAngebot

public class WettAngebot extends Object
Represents a betting offer.

Works like a simple mini ORM.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) long
     
    (package private) long
     
    (package private) double
     
    (package private) double
     
    (package private) double
     
    (package private) long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    WettAngebot(long spielId, long userId, double team0quote, double team1quote, double team2quote)
    Represents a betting offer.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes the current betting offer from the database.
    fromDB(long id)
    Retrieves a betting offer from the database based on the provided ID.
    Retrieves all betting offers from the database.
    getAllForBuchmacher(long buchmacherID)
    Retrieves all betting offers associated with a specific bookmaker from the database.
    getAllForSpiel(long spielId)
    Retrieves all betting offers associated with a specific game from the database.
    long
    Gets the ID of the betting offer.
    long
    Gets the ID of the game associated with the betting offer.
    double
    Gets the quote for team 0.
    double
    Gets the quote for team 1.
    double
    Gets the quote for team 2.
    long
    Gets the ID of the user who placed the betting offer.
    void
    Inserts a new betting offer into the database.
    boolean
    Checks if the betting offer is already in the database.
    private static Map<Long,WettAngebot>
    Retrieves a map of betting offers from the database based on the provided SQL statement.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • id

      long id
    • spielId

      long spielId
    • userId

      long userId
    • team0quote

      double team0quote
    • team1quote

      double team1quote
    • team2quote

      double team2quote
  • Constructor Details

    • WettAngebot

      public WettAngebot(long spielId, long userId, double team0quote, double team1quote, double team2quote)
      Represents a betting offer.
      Parameters:
      spielId - the ID of the game associated with the offer
      userId - the ID of the user who placed the offer
      team0quote - the quote for team 0
      team1quote - the quote for team 1
      team2quote - the quote for team 2
  • Method Details

    • insert

      public void insert()
      Inserts a new betting offer into the database.
    • fromDB

      public static WettAngebot fromDB(long id)
      Retrieves a betting offer from the database based on the provided ID.
      Parameters:
      id - The ID of the betting offer to retrieve from the database.
      Returns:
      The retrieved betting offer, or null if it doesn't exist or an error occurs.
    • getAll

      public static Map<Long,WettAngebot> getAll()
      Retrieves all betting offers from the database.
      Returns:
      A map containing the retrieved betting offers, where the keys are the IDs of the offers and the values are the corresponding WettAngebot objects. Returns null if an error occurs.
    • getAllForSpiel

      public static Map<Long,WettAngebot> getAllForSpiel(long spielId)
      Retrieves all betting offers associated with a specific game from the database.
      Parameters:
      spielId - The ID of the game to retrieve the betting offers for.
      Returns:
      A map containing the retrieved betting offers, where the keys are the IDs of the offers and the values are the corresponding WettAngebot objects. Returns null if an error occurs.
    • getAllForBuchmacher

      public static Map<Long,WettAngebot> getAllForBuchmacher(long buchmacherID)
      Retrieves all betting offers associated with a specific bookmaker from the database.
      Parameters:
      buchmacherID - The ID of the bookmaker to retrieve the betting offers for.
      Returns:
      A map containing the retrieved betting offers, where the keys are the IDs of the offers and the values are the corresponding WettAngebot objects. Returns null if an error occurs during retrieval.
    • sqlFromDb

      private static Map<Long,WettAngebot> sqlFromDb(PreparedStatement statement) throws SQLException
      Retrieves a map of betting offers from the database based on the provided SQL statement.
      Parameters:
      statement - The prepared statement used to execute the SQL query.
      Returns:
      A map containing the retrieved betting offers, where the keys are the IDs of the offers and the values are the corresponding WettAngebot objects.
      Throws:
      SQLException - If an error occurs during the execution of the SQL query.
    • delete

      public void delete()
      Deletes the current betting offer from the database.

      This method deletes the current betting offer from the database by executing an SQL DELETE statement. The betting offer to be deleted is determined based on the ID of the current object.

      Throws:
      SQLException - If an error occurs during the execution of the SQL statement.
    • getTeam0Quote

      public double getTeam0Quote()
      Gets the quote for team 0.
      Returns:
      The quote for team 0.
    • getTeam1Quote

      public double getTeam1Quote()
      Gets the quote for team 1.
      Returns:
      The quote for team 1.
    • getTeam2Quote

      public double getTeam2Quote()
      Gets the quote for team 2.
      Returns:
      The quote for team 2.
    • getId

      public long getId()
      Gets the ID of the betting offer.
      Returns:
      The ID of the betting offer.
    • getSpielId

      public long getSpielId()
      Gets the ID of the game associated with the betting offer.
      Returns:
      The ID of the game associated with the betting offer.
    • getUserId

      public long getUserId()
      Gets the ID of the user who placed the betting offer.
      Returns:
      The ID of the user who placed the betting offer.
    • isInDb

      public boolean isInDb()
      Checks if the betting offer is already in the database.
      Returns:
      true if the betting offer is in the database, false otherwise.