Package com.syzygy.events.database
Class User
- All Implemented Interfaces:
Database.Dissolvable
,Database.UpdateListener
An instance of a user database item
- A user can be edited
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Listeners for the creation of new notifications where the receiver is this userNested classes/interfaces inherited from class com.syzygy.events.database.DatabaseInstance
DatabaseInstance.DeletionType, DatabaseInstance.InstancePropertyWrapper<W extends DatabaseInstance<W>>, DatabaseInstance.PropertyField<V,
W extends DatabaseInstance<W>>, DatabaseInstance.PropertyWrapper<V, W extends DatabaseInstance<W>> Nested classes/interfaces inherited from interface com.syzygy.events.database.Database.UpdateListener
Database.UpdateListener.Type
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final DatabaseInstance.PropertyField<?,
?>[] The list of the fields defined for a UserFields inherited from class com.syzygy.events.database.DatabaseInstance
db, iproperties, properties
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected User
cast()
Gets this instance casted to the generic typeReturns the name that should be given to the image instance.com.google.firebase.Timestamp
getEmail()
getName()
isAdmin()
boolean
NewInstance
(Database db, String deviceID, String name, String description, android.net.Uri profileImage, String facilityID, String email, String phoneNumber, Boolean organizerNotifications, Boolean adminNotifications, Boolean isAdmin, Database.InitializationListener<User> listener) Validates and creates a new User instance in the database using the given data.protected void
requiredFirstDelete
(int deletionType, Consumer<Boolean> listener) Deletes any sub objects that are not instancesboolean
boolean
setDescription
(String val) boolean
setFacility
(Facility val) Sets the Facility instance.boolean
setFacilityID
(String val, Consumer<Boolean> onComplete) boolean
boolean
boolean
setPhoneNumber
(String val) void
setProfileImage
(android.net.Uri image, Consumer<Boolean> onComplete) Sets the Image instance.protected List<android.util.Pair<com.google.firebase.firestore.Query,
Database.Collections>> update
(String name, String description, android.net.Uri profileImage, String email, String phoneNumber, Boolean organizerNotifications, Boolean adminNotifications, Boolean isAdmin, Consumer<Boolean> onComplete) Validates and updates all properties of the user.update
(String name, String description, String email, String phoneNumber, Boolean organizerNotifications, Boolean adminNotifications, Boolean isAdmin, Consumer<Boolean> onComplete) Validates and updates all properties of the user.Methods inherited from class com.syzygy.events.database.DatabaseInstance
addInitializationListener, addListener, assertNotIllegalState, deleteInstance, dereferenceInstance, dissolve, dissolve, doesPropertyLoadInstance, fetch, fetch, fullDissolve, getAssociatedImage, getCollection, getCollectionReference, getData, getDatabaseID, getDocumentID, getDocumentReference, getFields, getPropertyInstance, getPropertyInstanceI, getPropertyValue, getPropertyValueI, initializeData, isDataValid, isDataValid, isLegalState, isPropertyEditable, isPropertyValid, isPropertyValid, isReferenced, modifyData, notifyUpdate, onUpdate, processUpdate, removeListener, setAssociatedImage, setPropertyInstance, setPropertyValue, subDereferenceInstance, subInitialize, toString, updateDataFromDatabase, updateDataFromMap, updateDataFromMap
-
Field Details
-
fields
The list of the fields defined for a User
-
-
Constructor Details
-
User
Checks to make sure the generic type is the type of this instance- Parameters:
db
- The databasedeviceID
- The id of the device associated with the user- Throws:
ClassCastException
-
-
Method Details
-
cast
Description copied from class:DatabaseInstance
Gets this instance casted to the generic type- Specified by:
cast
in classDatabaseInstance<User>
- Returns:
- This as the generic type
-
getName
-
setName
-
getDescription
-
setDescription
-
getProfileImageID
-
getFacilityID
-
setFacilityID
-
getEmail
-
setEmail
-
getPhoneNumber
-
setPhoneNumber
-
getAdminNotifications
-
setAdminNotifications
-
getOrganizerNotifications
-
setOrganizerNotifications
-
isAdmin
-
makeAdmin
-
getCreatedTime
public com.google.firebase.Timestamp getCreatedTime() -
getProfileImage
-
getAssociatedImageLocName
Description copied from class:DatabaseInstance
Returns the name that should be given to the image instance. If no image is associated, returns null- Overrides:
getAssociatedImageLocName
in classDatabaseInstance<User>
-
getInitials
-
setProfileImage
@StirsDeep(what="The previous Image") public void setProfileImage(@Nullable android.net.Uri image, Consumer<Boolean> onComplete) Sets the Image instance. This function will create a new reference to the instance.- Parameters:
image
- The new instanceonComplete
- called on completion with if the update was successful- See Also:
-
getFacility
-
setFacility
Sets the Facility instance. This function will create a new reference to the instance.- Parameters:
val
- The new instance
-
update
@StirsDeep(what="The previous image") public Set<Integer> update(String name, String description, @Nullable android.net.Uri profileImage, String email, String phoneNumber, Boolean organizerNotifications, Boolean adminNotifications, Boolean isAdmin, Consumer<Boolean> onComplete) Validates and updates all properties of the user. If the user changes, a notification is sent to listeners once and the database is updated once- Parameters:
name
- The name of the userdescription
- The description of the userprofileImage
- the profile imageemail
- The email of the userphoneNumber
- The phone number of the userorganizerNotifications
- If the user should receive notifications from organizersadminNotifications
- If the user should receive notifications from adminsisAdmin
- If the user has admin privilegesonComplete
- called once update is complete with weather the update was successful. Not called if properties are invalid- Returns:
- If the user changed as a result
- See Also:
-
update
public Set<Integer> update(String name, String description, String email, String phoneNumber, Boolean organizerNotifications, Boolean adminNotifications, Boolean isAdmin, Consumer<Boolean> onComplete) Validates and updates all properties of the user. If the user changes, a notification is sent to listeners once and the database is updated once- Parameters:
name
- The name of the userdescription
- The description of the useremail
- The email of the userphoneNumber
- The phone number of the userorganizerNotifications
- If the user should receive notifications from organizersadminNotifications
- If the user should receive notifications from adminsisAdmin
- If the user has admin privilegesonComplete
- will always be true and will be called before return- Returns:
- All invalid ids
- See Also:
-
subInstanceCascadeDeleteQuery
protected List<android.util.Pair<com.google.firebase.firestore.Query,Database.Collections>> subInstanceCascadeDeleteQuery()- Specified by:
subInstanceCascadeDeleteQuery
in classDatabaseInstance<User>
- Returns:
- A list of all querries that should be run whose instances will be deleted when this instance is deleted
-
requiredFirstDelete
Description copied from class:DatabaseInstance
Deletes any sub objects that are not instances- Overrides:
requiredFirstDelete
in classDatabaseInstance<User>
- Parameters:
deletionType
- TheDatabaseInstance.DeletionType
reason this instance is being deletedlistener
- Called before the instance and sub instances are deleted; they are only deleted if this returns true
-
NewInstance
@MustStir public static Set<Integer> NewInstance(Database db, String deviceID, String name, String description, @Nullable android.net.Uri profileImage, @Dilutes String facilityID, String email, String phoneNumber, Boolean organizerNotifications, Boolean adminNotifications, Boolean isAdmin, Database.InitializationListener<User> listener) Validates and creates a new User instance in the database using the given data.- Parameters:
db
- The databasedeviceID
- The ID of the device associated with the Username
- The name of the userdescription
- The description of the userprofileImage
- the profileImagefacilityID
- The ID of the user's facilityemail
- The email of the userphoneNumber
- The phone number of the userorganizerNotifications
- If the user should receive notifications from organizersadminNotifications
- If the user should receive notifications from adminsisAdmin
- If the user has admin privilegeslistener
- Will be called once the user is initialized. Is not called if the data is invalid- Returns:
- The property id of all invalid properties
- Throws:
IllegalArgumentException
- If deviceId is invalid- See Also:
-