Interface UserService

  • All Known Implementing Classes:
    UserServiceImpl

    public interface UserService
    The service that works with the User model

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void delete​(long id)
      Deletes the user record based off the provided primary key
      void deleteAll()
      Deletes all records and their associated records from the database
      java.util.List<User> findAll()
      Returns a list of all the users
      java.util.List<User> findAllByLastName​(java.lang.String lastname)
      A list of users whose last name contains the given substring
      User findByEmail​(java.lang.String email)
      Returns the user with the given email address
      User findById​(long id)
      Returns the user with the given primary key
      User findByUsername​(java.lang.String username)
      Returns the user with the given username
      java.util.List<User> findUsernamesContaining​(java.lang.String username)
      A list of users whose username contains the given substring
      User save​(User user)
      Given a complete user object, saves that user object in the database If a primary key is provided, the record is completely replaced If no primary key is provided, one is automatically generated and the record is added to the database
      User update​(User user, long id)
      Updates the provided fields in the user record referenced by the primary key
    • Method Detail

      • findAll

        java.util.List<User> findAll()
        Returns a list of all the users
        Returns:
        List of users
      • findById

        User findById​(long id)
        Returns the user with the given primary key
        Parameters:
        id - The primary key (long) of the user you seek
        Returns:
        User object with the given primary key or throws an exception if not found
      • findByUsername

        User findByUsername​(java.lang.String username)
        Returns the user with the given username
        Parameters:
        username - The username (String) of the user you seek
        Returns:
        User object with given username or throws an exception if not found
      • findByEmail

        User findByEmail​(java.lang.String email)
        Returns the user with the given email address
        Parameters:
        email - The email (String) of the user you seek
        Returns:
        User object with the given email or throws an exception if not found
      • findUsernamesContaining

        java.util.List<User> findUsernamesContaining​(java.lang.String username)
        A list of users whose username contains the given substring
        Parameters:
        username - The substring (String) containing the username
        Returns:
        List of users whose username contains the given substring
      • findAllByLastName

        java.util.List<User> findAllByLastName​(java.lang.String lastname)
        A list of users whose last name contains the given substring
        Parameters:
        lastname - The substring (String) containing the last name
        Returns:
        List of users whose last name contains the given substring
      • save

        User save​(User user)
        Given a complete user object, saves that user object in the database If a primary key is provided, the record is completely replaced If no primary key is provided, one is automatically generated and the record is added to the database
        Parameters:
        user - The user object (User) to be saved
        Returns:
        The saved user object including any automatically generated fields
      • update

        User update​(User user,
                    long id)
        Updates the provided fields in the user record referenced by the primary key
        Parameters:
        user - Only the user fields to be updated
        id - The primary key (long) of the user to be updated
        Returns:
        Update user object
      • delete

        void delete​(long id)
        Deletes the user record based off the provided primary key
        Parameters:
        id - The primary key (long) of the user to be deleted
      • deleteAll

        void deleteAll()
        Deletes all records and their associated records from the database