Package nl.minetopiasdb.api.phone
Class PhoneManager
java.lang.Object
nl.minetopiasdb.api.phone.PhoneManager
Class for managing phones.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddContact
(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.createNewPhone
(int phonenumber, UUID owner) Automatically register a new phonenumber.createPhone
(int phonenumber, UUID owner) Deprecated.getAllContacts
(int phonenumber) Get all the contacts of the provided phonenumber.Get a list of all phone instances.getContacts
(int phonenumber) Deprecated.You should usegetAllContacts(int)
instead.static PhoneManager
Get an instance of PhoneManagergetPhone
(int phonenumber) Get the Phone object for provided phonenumberDeprecated.You should usegetAllPhones()
instead.int
Get a random phone number (could be taken!)boolean
isAvailable
(int phonenumber) Check if given phonenumber is availableremoveContact
(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
-
getPhone
Get the Phone object for provided phonenumber- Parameters:
phonenumber
- phonenumber- Returns:
- Phone object
-
createNewPhone
Automatically register a new phonenumber. Returns null when phonenumber is taken.- Parameters:
phonenumber
- phonenumber of this phoneowner
- owner of this phone- Returns:
- CompletableFuture containing a phone object or null when phonenumber is taken
-
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
Get all the contacts of the provided phonenumber.- Parameters:
phonenumber
- phonenumber- Returns:
- list of PhoneContact objects
-
addContact
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
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.UsecreateNewPhone(int, UUID)
instead.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
-
getPhones
Deprecated.You should usegetAllPhones()
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.You should usegetAllContacts(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
-
createNewPhone(int, UUID)
instead.