@@ -68,6 +68,7 @@ public static <T> T singleResult(@Nullable Collection<T> results) throws Incorre
68
68
* @return the single result object, or {@code null} if none
69
69
* @throws IncorrectResultSizeDataAccessException if more than one
70
70
* element has been found in the given Stream
71
+ * @since 6.1
71
72
*/
72
73
@ Nullable
73
74
public static <T > T singleResult (@ Nullable Stream <T > results ) throws IncorrectResultSizeDataAccessException {
@@ -91,13 +92,14 @@ public static <T> T singleResult(@Nullable Stream<T> results) throws IncorrectRe
91
92
* @return the single result object, or {@code null} if none
92
93
* @throws IncorrectResultSizeDataAccessException if more than one
93
94
* element has been found in the given Iterator
95
+ * @since 6.1
94
96
*/
95
97
@ Nullable
96
98
public static <T > T singleResult (@ Nullable Iterator <T > results ) throws IncorrectResultSizeDataAccessException {
97
99
if (results == null ) {
98
100
return null ;
99
101
}
100
- T result = results .hasNext () ? results .next () : null ;
102
+ T result = ( results .hasNext () ? results .next () : null ) ;
101
103
if (results .hasNext ()) {
102
104
throw new IncorrectResultSizeDataAccessException (1 );
103
105
}
@@ -112,6 +114,7 @@ public static <T> T singleResult(@Nullable Iterator<T> results) throws Incorrect
112
114
* @return the single optional result object, or {@code Optional.empty()} if none
113
115
* @throws IncorrectResultSizeDataAccessException if more than one
114
116
* element has been found in the given Collection
117
+ * @since 6.1
115
118
*/
116
119
public static <T > Optional <T > optionalResult (@ Nullable Collection <T > results ) throws IncorrectResultSizeDataAccessException {
117
120
return Optional .ofNullable (singleResult (results ));
@@ -125,6 +128,7 @@ public static <T> Optional<T> optionalResult(@Nullable Collection<T> results) th
125
128
* @return the single optional result object, or {@code Optional.empty()} if none
126
129
* @throws IncorrectResultSizeDataAccessException if more than one
127
130
* element has been found in the given Stream
131
+ * @since 6.1
128
132
*/
129
133
public static <T > Optional <T > optionalResult (@ Nullable Stream <T > results ) throws IncorrectResultSizeDataAccessException {
130
134
return Optional .ofNullable (singleResult (results ));
@@ -138,6 +142,7 @@ public static <T> Optional<T> optionalResult(@Nullable Stream<T> results) throws
138
142
* @return the single optional result object, or {@code Optional.empty()} if none
139
143
* @throws IncorrectResultSizeDataAccessException if more than one
140
144
* element has been found in the given Iterator
145
+ * @since 6.1
141
146
*/
142
147
public static <T > Optional <T > optionalResult (@ Nullable Iterator <T > results ) throws IncorrectResultSizeDataAccessException {
143
148
return Optional .ofNullable (singleResult (results ));
0 commit comments