Interface AvatarRepository

    • Method Detail

      • loadDefault

        @NotNull
        @NotNull CacheableAvatarSupplier loadDefault​(@NotNull
                                                     @NotNull AvatarType type,
                                                     int size)
        Loads a default avatar for the specified type in an approximation of the requested size. Default avatars are only available in a fixed set of sizes, and dynamic sizes are not created, so the request size is normalized into that set.
        Parameters:
        type - the type of object to retrieve a default avatar for
        size - the size to retrieve the avatar in
        Returns:
        a supplier for accessing the requested default avatar
      • load

        @Nullable
        @Nullable CacheableAvatarSupplier load​(@NotNull
                                               @NotNull AvatarType type,
                                               @NotNull
                                               @NotNull String id,
                                               int size)
        Retrieves the current avatar for the specified object and type, or a null if no avatar has been stored.
        Parameters:
        type - the type of object associated with the provided ID
        id - the object's ID
        size - the size to retrieve the avatar in
        Returns:
        a supplier for accessing the requested avatar
      • store

        void store​(@NotNull
                   @NotNull AvatarType type,
                   @NotNull
                   @NotNull String id,
                   @NotNull
                   @NotNull AvatarSupplier supplier)
        Stores the provided avatar for the specified object and type.

        The file size for the avatar image is not checked by the repository. That restriction is expected to be applied at the system's edges (REST, SpringMVC, etc.).

        Parameters:
        type - the type of object associated with the provided ID
        id - the object's ID
        supplier - a supplier providing access to the avatar data
      • isStored

        boolean isStored​(@NotNull
                         @NotNull AvatarType type,
                         @NotNull
                         @NotNull String id)
        Retrieves a flag indicating whether an avatar has been stored for the specified object and type.
        Parameters:
        type - the type of object associated with the provided ID
        id - the object's ID
        Returns:
        true if a local avatar exists for the specified object; otherwise, false
      • delete

        void delete​(@NotNull
                    @NotNull AvatarType type,
                    @NotNull
                    @NotNull String id)
        Deletes any stored avatars for the specified object and type. This removes the original as well as any scaled copies that have been created based on requested sizes.
        Parameters:
        type - the type of object associated with the provided ID
        id - the object's ID
      • move

        void move​(@NotNull
                  @NotNull AvatarType type,
                  @NotNull
                  @NotNull String oldId,
                  @NotNull
                  @NotNull String newId)
        Moves any stored avatars for the specified object and type from the old ID to the new ID.
        Parameters:
        type - the type of object associated with the provided ID
        oldId - the object's old ID
        newId - the object's new ID
      • getVersionId

        @NotNull
        @NotNull Optional<Long> getVersionId​(@NotNull
                                             @NotNull AvatarType type,
                                             @NotNull
                                             @NotNull String id)
        Retrieves a version identifier for the avatar with the specified object and type.
        Parameters:
        type - the type of the object to retrieve a version for
        id - the Object's ID
        Returns:
        a version identifier for the avatar identified by the id and type, which will change only when the underlying avatar is modified