Class QuerySvc

java.lang.Object
com.djrapitops.plan.query.QuerySvc
All Implemented Interfaces:
QueryService

@Singleton public class QuerySvc extends Object implements QueryService
  • Constructor Details

  • Method Details

    • register

      public void register()
    • getDBType

      public String getDBType()
      Description copied from interface: QueryService
      Get what kind of database is in use.
      Specified by:
      getDBType in interface QueryService
      Returns:
      SQLITE or MYSQL
    • query

      public <T> T query(String sql, QueryService.ThrowingFunction<PreparedStatement,T> performQuery)
      Description copied from interface: QueryService
      Perform a query against Plan database.

      Blocks thread until query is complete.

      Specified by:
      query in interface QueryService
      Type Parameters:
      T - Type of results.
      Parameters:
      sql - SQL String to execute, can contain parameterized queries (?).
      performQuery - set your parameters to the PreparedStatement and execute the query, return results.
      Returns:
      The object returned by results.
    • execute

      public Future<?> execute(String sql, QueryService.ThrowingConsumer<PreparedStatement> performStatement)
      Description copied from interface: QueryService
      Execute SQL against Plan database.

      Does not block thread, SQL is executed in a single transaction to the database.

      Differs from QueryService.query(String, ThrowingFunction) in that no results are returned.

      Specified by:
      execute in interface QueryService
      Parameters:
      sql - SQL String to execute, can contain parameterized queries (?).
      performStatement - set your parameters to the PreparedStatement and execute the statement.
      Returns:
      A Future that tells when the transaction has completed. Blocks thread if Future#get is called.
    • subscribeToPlayerRemoveEvent

      public void subscribeToPlayerRemoveEvent(Consumer<UUID> eventListener)
      Description copied from interface: QueryService
      Used for getting notified about removal of player data.

      SQL for removing this player's data should be executed when this occurs.

      Example usage: subscribeToPlayerRemoveEvent(playerUUID -> { do stuff })

      Specified by:
      subscribeToPlayerRemoveEvent in interface QueryService
      Parameters:
      eventListener - Functional interface that is called on the event.
    • subscribeDataClearEvent

      public void subscribeDataClearEvent(QueryService.VoidFunction eventListener)
      Description copied from interface: QueryService
      Used for getting notified about removal of ALL data.

      SQL for removing all extra tables (and data) should be performed

      Example usage: subscribeDataClearEvent(() -> { do stuff })

      Specified by:
      subscribeDataClearEvent in interface QueryService
      Parameters:
      eventListener - Functional interface that is called on the event.
    • playerRemoved

      public void playerRemoved(UUID playerUUID)
    • dataCleared

      public void dataCleared()
    • getServerUUID

      public Optional<UUID> getServerUUID()
      Description copied from interface: QueryService
      Get the UUID of this server.
      Specified by:
      getServerUUID in interface QueryService
      Returns:
      Optional of the server UUID, empty if server did not start properly.
    • getCommonQueries

      public CommonQueries getCommonQueries()
      Description copied from interface: QueryService
      Perform some commonly wanted queries.
      Specified by:
      getCommonQueries in interface QueryService
      Returns:
      CommonQueries implementation.