|
18 | 18 | * <p>
|
19 | 19 | * There are two related concepts to understand:
|
20 | 20 | * <ul>
|
21 |
| - * <li>CacheKeyMapper - maps/extracts a key used to reference the associated resource in the cache</li> |
22 |
| - * <li>Object equals usage - compares if the two resources are the same or same version.</li> |
| 21 | + * <li>{@link CacheKeyMapper} - maps/extracts a key used to reference the associated resource in the |
| 22 | + * cache</li> |
| 23 | + * <li>External resources <strong>must</strong> properly implement {@link Object#equals(Object)} as |
| 24 | + * the cache uses {@code equals} to check if the resource has changed</li> |
23 | 25 | * </ul>
|
24 |
| - * |
25 |
| - * When a resource is added for a primary resource its key is used to put in a map. Equals is used |
26 |
| - * to compare if it's still the same resource, or an updated version of it. Event is emitted only if |
27 |
| - * a new resource(s) is received or actually updated or deleted. Delete is detected by a missing |
28 |
| - * key. |
| 26 | + * <p> |
| 27 | + * When a resource is added for a primary resource its key is used to put in a map. |
| 28 | + * {@link Object#equals(Object)} is used to compare if it's still the same resource, or an updated |
| 29 | + * version of it. Event is emitted only if a new resource(s) is received or actually updated or |
| 30 | + * deleted. Delete is detected by a missing key. |
29 | 31 | *
|
30 | 32 | * @param <R> type of polled external secondary resource
|
31 | 33 | * @param <P> primary resource
|
32 | 34 | */
|
33 | 35 | public abstract class ExternalResourceCachingEventSource<R, P extends HasMetadata>
|
34 | 36 | extends AbstractResourceEventSource<R, P> implements RecentOperationCacheFiller<R> {
|
35 | 37 |
|
36 |
| - private static Logger log = LoggerFactory.getLogger(ExternalResourceCachingEventSource.class); |
| 38 | + private static final Logger log = |
| 39 | + LoggerFactory.getLogger(ExternalResourceCachingEventSource.class); |
37 | 40 |
|
38 | 41 | protected final CacheKeyMapper<R> cacheKeyMapper;
|
39 | 42 |
|
@@ -89,7 +92,7 @@ protected synchronized void handleResources(Map<ResourceID, Set<R>> allNewResour
|
89 | 92 | var toDelete = cache.keySet().stream().filter(k -> !allNewResources.containsKey(k))
|
90 | 93 | .collect(Collectors.toList());
|
91 | 94 | toDelete.forEach(this::handleDelete);
|
92 |
| - allNewResources.forEach((primaryID, resources) -> handleResources(primaryID, resources)); |
| 95 | + allNewResources.forEach(this::handleResources); |
93 | 96 | }
|
94 | 97 |
|
95 | 98 | protected synchronized void handleResources(ResourceID primaryID, Set<R> newResources,
|
|
0 commit comments