|
47 | 47 | * @author Christoph Strobl
|
48 | 48 | * @author Yuki Yoshida
|
49 | 49 | * @author Réda Housni Alaoui
|
| 50 | + * @author Yanming Zhou |
50 | 51 | * @since 1.13
|
51 | 52 | * @soundtrack Henrik Freischlader Trio - Master Plan (Openness)
|
52 | 53 | */
|
@@ -186,13 +187,13 @@ public void publishEventsFrom(@Nullable Object object, ApplicationEventPublisher
|
186 | 187 | return;
|
187 | 188 | }
|
188 | 189 |
|
189 |
| - for (Object aggregateRoot : asCollection(object)) { |
| 190 | + for (Object aggregateRoot : asIterable(object)) { |
190 | 191 |
|
191 | 192 | if (!type.isInstance(aggregateRoot)) {
|
192 | 193 | continue;
|
193 | 194 | }
|
194 | 195 |
|
195 |
| - for (Object event : asCollection(ReflectionUtils.invokeMethod(publishingMethod, aggregateRoot))) { |
| 196 | + for (Object event : asIterable(ReflectionUtils.invokeMethod(publishingMethod, aggregateRoot))) { |
196 | 197 | publisher.publishEvent(event);
|
197 | 198 | }
|
198 | 199 |
|
@@ -262,21 +263,21 @@ private static Method getClearingMethod(AnnotationDetectionMethodCallback<?> cle
|
262 | 263 | }
|
263 | 264 |
|
264 | 265 | /**
|
265 |
| - * Returns the given source object as collection, i.e. collections are returned as is, objects are turned into a |
| 266 | + * Returns the given source object as iterable, i.e. iterables are returned as is, objects are turned into a |
266 | 267 | * one-element collection, {@literal null} will become an empty collection.
|
267 | 268 | *
|
268 | 269 | * @param source can be {@literal null}.
|
269 |
| - * @return |
| 270 | + * @return iterable |
270 | 271 | */
|
271 | 272 | @SuppressWarnings("unchecked")
|
272 |
| - private static Collection<Object> asCollection(@Nullable Object source) { |
| 273 | + private static Iterable<Object> asIterable(@Nullable Object source) { |
273 | 274 |
|
274 | 275 | if (source == null) {
|
275 | 276 | return Collections.emptyList();
|
276 | 277 | }
|
277 | 278 |
|
278 |
| - if (Collection.class.isInstance(source)) { |
279 |
| - return (Collection<Object>) source; |
| 279 | + if (Iterable.class.isInstance(source)) { |
| 280 | + return (Iterable<Object>) source; |
280 | 281 | }
|
281 | 282 |
|
282 | 283 | return Collections.singletonList(source);
|
|
0 commit comments