Class PhoneManager

java.lang.Object
nl.minetopiasdb.api.phone.PhoneManager

public class PhoneManager extends Object
Class for managing phones.
  • Constructor Details

    • PhoneManager

      public PhoneManager()
  • Method Details

    • getInstance

      public static PhoneManager getInstance()
      Get an instance of PhoneManager
      Returns:
      instance of PhoneManager
    • getPhone

      public CompletableFuture<Phone> getPhone(int phonenumber)
      Get the Phone object for provided phonenumber
      Parameters:
      phonenumber - phonenumber
      Returns:
      Phone object
    • createNewPhone

      public CompletableFuture<Phone> createNewPhone(int phonenumber, UUID owner)
      Automatically register a new phonenumber. Returns null when phonenumber is taken.
      Parameters:
      phonenumber - phonenumber of this phone
      owner - owner of this phone
      Returns:
      CompletableFuture containing a phone object or null when phonenumber is taken
    • getAllPhones

      public CompletableFuture<List<Phone>> getAllPhones()
      Get a list of all phone instances.

      NOTE: Please use this method async, since it will fetch the phonenumbers from the database directly.

      Returns:
      List of phone instances
    • getAllContacts

      public CompletableFuture<List<PhoneContact>> getAllContacts(int phonenumber)
      Get all the contacts of the provided phonenumber.
      Parameters:
      phonenumber - phonenumber
      Returns:
      list of PhoneContact objects
    • addContact

      public CompletableFuture<Integer> addContact(int phonenumber, int newContact)
      Add a contact to the provided phonenumber NOTE: Please use this method async, since it will run SQL operations in the main thread otherwise.
      Parameters:
      phonenumber - phonenumber (without '06' prefix)
      newContact - phone number of the new contact (without '06' prefix)
      Returns:
      amount of affected rows, should be 1 when adding was successful
    • removeContact

      public CompletableFuture<Integer> removeContact(int phonenumber, int contact)
      Remove a contact from a provided phonenumber
      Parameters:
      phonenumber - phonenumber (without '06' prefix)
      contact - phone number of contact (without '06' prefix)
      Returns:
      CompletableFuture containing the amount of modified rows
    • getRandomPhoneNumber

      public int getRandomPhoneNumber()
      Get a random phone number (could be taken!)
      Returns:
      random phone number
    • createPhone

      @Deprecated public Phone createPhone(int phonenumber, UUID owner)
      Deprecated.
      Automatically register a new phonenumber. Returns null when phonenumber is taken.

      NOTE: Please use this method async, since it will run SQL operations in the main thread otherwise.

      Parameters:
      phonenumber - phonenumber of this phone
      owner - owner of this phone
      Returns:
      Phone object
    • getPhones

      @Deprecated public List<Phone> getPhones()
      Deprecated.
      You should use getAllPhones() instead.
      Get a list of all phone instances.

      NOTE: Please use this method async, since it will fetch the phonenumbers from the database directly.

      Returns:
      List of phone instances
    • getContacts

      @Deprecated public List<PhoneContact> getContacts(int phonenumber)
      Deprecated.
      You should use getAllContacts(int) instead.
      Get all the contacts of the provided phonenumber. NOTE: Please use this method async, since it will run SQL operations in the main thread otherwise.
      Parameters:
      phonenumber - phonenumber
      Returns:
      list of PhoneContact objects
    • isAvailable

      public boolean isAvailable(int phonenumber)
      Check if given phonenumber is available
      Parameters:
      phonenumber - phonenumber that needs to be checked
      Returns:
      true if provided phonenumber is available