Package nl.minetopiasdb.api.phone
Class PhoneManager
java.lang.Object
nl.minetopiasdb.api.phone.PhoneManager
Class for managing phones.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.static PhoneManager
Get an instance of PhoneManagergetPhone(int phonenumber)
Get the Phone object for provided phonenumberGet a list of all phone instances.int
Get a random phone number (could be taken!)boolean
isAvailable(int phonenumber)
Check if given phonenumber is availablevoid
removeContact(int phonenumber, int contact)
Remove a contact from a provided phonenumber
-
Constructor Details
-
PhoneManager
public PhoneManager()
-
-
Method Details
-
getInstance
Get an instance of PhoneManager- Returns:
- instance of PhoneManager
-
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
Get the Phone object for provided phonenumber- Parameters:
phonenumber
- phonenumber- Returns:
- Phone object
-
createPhone
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 phoneowner
- owner of this phone- Returns:
- Phone object
-
getContacts
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
-