Class PhoneManager

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

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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.
    createPhone​(int phonenumber, UUID owner)
    Automatically register a new phonenumber.
    getContacts​(int phonenumber)
    Get all the contacts of the provided phonenumber.
    Get an instance of PhoneManager
    getPhone​(int phonenumber)
    Get the Phone object for provided phonenumber
    Get a list of all phone instances.
    int
    Get a random phone number (could be taken!)
    boolean
    isAvailable​(int phonenumber)
    Check if given phonenumber is available
    void
    removeContact​(int phonenumber, int contact)
    Remove a contact from a provided phonenumber

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PhoneManager

      public PhoneManager()
  • Method Details

    • getInstance

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

      public List<Phone> getPhones()
      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
    • getPhone

      public Phone getPhone(int phonenumber)
      Get the Phone object for provided phonenumber
      Parameters:
      phonenumber - phonenumber
      Returns:
      Phone object
    • createPhone

      public Phone createPhone(int phonenumber, UUID owner)
      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
    • getContacts

      public List<PhoneContact> getContacts(int phonenumber)
      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:
      hashmap with longs and integers, integers are the phonenumbers without the '06' prefix. longs are the mysql row ids
    • addContact

      public void 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)
    • removeContact

      public void 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)
    • 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
    • getRandomPhoneNumber

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