Class CollectionUtils
java.lang.Object
io.github.blyznytsiaorg.bibernate.utils.CollectionUtils
Utility class for common operations on collections.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
isEmpty
(Collection<?> collection) Checks if a collection is empty.boolean
isNotEmpty
(Collection<?> collection) Checks if a collection is not empty.void
requireNonEmpty
(Collection<?> collection, String message) Requires that a collection is not empty, throwing an exception with the specified message if it is.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
isEmpty
Checks if a collection is empty.- Parameters:
collection
- the collection to check- Returns:
- true if the collection is null or empty, false otherwise
-
isNotEmpty
Checks if a collection is not empty.- Parameters:
collection
- the collection to check- Returns:
- true if the collection is not null and not empty, false otherwise
-
requireNonEmpty
Requires that a collection is not empty, throwing an exception with the specified message if it is.- Parameters:
collection
- the collection to checkmessage
- the message to include in the exception if the collection is empty- Throws:
CollectionIsEmptyException
- if the collection is empty
-