spring-framework / org.springframework.dao.support / DataAccessUtils / requiredUniqueResult

requiredUniqueResult

open static fun <T : Any> requiredUniqueResult(@Nullable results: MutableCollection<T>): T

Return a unique result object from the given Collection.

Throws an exception if 0 or more than 1 instance found.

Parameters

results - the result Collection (can be null but is not expected to contain null elements)

Exceptions

IncorrectResultSizeDataAccessException - if more than one result object has been found in the given Collection

EmptyResultDataAccessException - if no result object at all has been found in the given Collection

Return
the unique result object

See Also
org.springframework.util.CollectionUtils#hasUniqueObject