Class User

All Implemented Interfaces:
Database.Dissolvable, Database.UpdateListener

@Dissolves public class User extends DatabaseInstance<User>
An instance of a user database item - A user can be edited
  • Field Details

  • Constructor Details

  • Method Details

    • cast

      @Observes protected User cast()
      Description copied from class: DatabaseInstance
      Gets this instance casted to the generic type
      Specified by:
      cast in class DatabaseInstance<User>
      Returns:
      This as the generic type
    • getName

      public String getName()
    • setName

      public boolean setName(String val)
    • getDescription

      public String getDescription()
    • setDescription

      public boolean setDescription(String val)
    • getProfileImageID

      public String getProfileImageID()
    • getFacilityID

      public String getFacilityID()
    • setFacilityID

      public boolean setFacilityID(@Dilutes String val, Consumer<Boolean> onComplete)
    • getEmail

      public String getEmail()
    • setEmail

      public boolean setEmail(String val)
    • getPhoneNumber

      public String getPhoneNumber()
    • setPhoneNumber

      public boolean setPhoneNumber(String val)
    • getAdminNotifications

      public Boolean getAdminNotifications()
    • setAdminNotifications

      public boolean setAdminNotifications(Boolean val)
    • getOrganizerNotifications

      public Boolean getOrganizerNotifications()
    • setOrganizerNotifications

      public boolean setOrganizerNotifications(Boolean val)
    • isAdmin

      public Boolean isAdmin()
    • makeAdmin

      public boolean makeAdmin(Boolean val)
    • getCreatedTime

      public com.google.firebase.Timestamp getCreatedTime()
    • getProfileImage

      @Observes public Image getProfileImage()
    • getAssociatedImageLocName

      public String 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 class DatabaseInstance<User>
    • getInitials

      public String 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 instance
      onComplete - called on completion with if the update was successful
      See Also:
    • getFacility

      @Observes public Facility getFacility()
    • setFacility

      @StirsDeep(what="The previous Image") public Boolean setFacility(@Nullable @Dilutes Facility val)
      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 user
      description - The description of the user
      profileImage - the profile image
      email - The email of the user
      phoneNumber - The phone number of the user
      organizerNotifications - If the user should receive notifications from organizers
      adminNotifications - If the user should receive notifications from admins
      isAdmin - If the user has admin privileges
      onComplete - 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 user
      description - The description of the user
      email - The email of the user
      phoneNumber - The phone number of the user
      organizerNotifications - If the user should receive notifications from organizers
      adminNotifications - If the user should receive notifications from admins
      isAdmin - If the user has admin privileges
      onComplete - 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 class DatabaseInstance<User>
      Returns:
      A list of all querries that should be run whose instances will be deleted when this instance is deleted
    • requiredFirstDelete

      protected void requiredFirstDelete(int deletionType, Consumer<Boolean> listener)
      Description copied from class: DatabaseInstance
      Deletes any sub objects that are not instances
      Overrides:
      requiredFirstDelete in class DatabaseInstance<User>
      Parameters:
      deletionType - The DatabaseInstance.DeletionType reason this instance is being deleted
      listener - 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 database
      deviceID - The ID of the device associated with the User
      name - The name of the user
      description - The description of the user
      profileImage - the profileImage
      facilityID - The ID of the user's facility
      email - The email of the user
      phoneNumber - The phone number of the user
      organizerNotifications - If the user should receive notifications from organizers
      adminNotifications - If the user should receive notifications from admins
      isAdmin - If the user has admin privileges
      listener - 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: