|
|
|
@ -116,7 +116,9 @@ public abstract class DataAccessUtils { |
|
|
|
* element has been found in the given Collection |
|
|
|
* element has been found in the given Collection |
|
|
|
* @since 6.1 |
|
|
|
* @since 6.1 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static <T extends @Nullable Object> Optional<@NonNull T> optionalResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException { |
|
|
|
public static <T extends @Nullable Object> Optional<@NonNull T> optionalResult(@Nullable Collection<T> results) |
|
|
|
|
|
|
|
throws IncorrectResultSizeDataAccessException { |
|
|
|
|
|
|
|
|
|
|
|
return Optional.ofNullable(singleResult(results)); |
|
|
|
return Optional.ofNullable(singleResult(results)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -159,7 +161,9 @@ public abstract class DataAccessUtils { |
|
|
|
* @throws EmptyResultDataAccessException if no element at all |
|
|
|
* @throws EmptyResultDataAccessException if no element at all |
|
|
|
* has been found in the given Collection |
|
|
|
* has been found in the given Collection |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static <T extends @Nullable Object> @NonNull T requiredSingleResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException { |
|
|
|
public static <T extends @Nullable Object> @NonNull T requiredSingleResult(@Nullable Collection<T> results) |
|
|
|
|
|
|
|
throws IncorrectResultSizeDataAccessException { |
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(results)) { |
|
|
|
if (CollectionUtils.isEmpty(results)) { |
|
|
|
throw new EmptyResultDataAccessException(1); |
|
|
|
throw new EmptyResultDataAccessException(1); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -185,7 +189,9 @@ public abstract class DataAccessUtils { |
|
|
|
* has been found in the given Collection |
|
|
|
* has been found in the given Collection |
|
|
|
* @since 5.0.2 |
|
|
|
* @since 5.0.2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static <T extends @Nullable Object> T nullableSingleResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException { |
|
|
|
public static <T extends @Nullable Object> T nullableSingleResult(@Nullable Collection<T> results) |
|
|
|
|
|
|
|
throws IncorrectResultSizeDataAccessException { |
|
|
|
|
|
|
|
|
|
|
|
// This is identical to the requiredSingleResult implementation but differs in the
|
|
|
|
// This is identical to the requiredSingleResult implementation but differs in the
|
|
|
|
// semantics of the incoming Collection (which we currently can't formally express)
|
|
|
|
// semantics of the incoming Collection (which we currently can't formally express)
|
|
|
|
if (CollectionUtils.isEmpty(results)) { |
|
|
|
if (CollectionUtils.isEmpty(results)) { |
|
|
|
|