Skip to content

Commit

Permalink
chore: Add convenience list and count without Filter
Browse files Browse the repository at this point in the history
Using a default implementation does not put any extra burden on the interface implementor
  • Loading branch information
Artur- committed Jan 16, 2025
1 parent ae42659 commit e2084ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@
*/
public interface CountService {

/**
* Counts the number of items, without any filtering.
*
* @return the number of items in the service
*/
default long count() {
return count(null);
}

/**
* Counts the number of items that match the given filter.
*
* @param filter
* the filter, or {@code null} to use no filter
* @return the number of items in the service that match the filter
*/
public long count(@Nullable Filter filter);
long count(@Nullable Filter filter);

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
* the type of object to list
*/
public interface ListService<T> {
/**
* Lists objects of the given type using the paging and sorting
* options provided in the parameters.
*
* @param pageable
* contains information about paging and sorting
* @return a list of objects or an empty list if no objects were found
*/
default List<T> list(Pageable pageable) {
return list(pageable, null);
}

/**
* Lists objects of the given type using the paging, sorting and filtering
* options provided in the parameters.
Expand Down

0 comments on commit e2084ac

Please sign in to comment.