public final class RefreshHelper extends Object implements Refreshable
Refreshable
. This object is typically included in an implementation
Refreshable
to implement Refreshable.refresh(Collection)
. It execute the class's own
supplied update logic, after updating all the object's dependencies. This also ensures that dependencies
are not updated multiple times.Constructor and Description |
---|
RefreshHelper(Callable<?> refreshRunnable) |
Modifier and Type | Method and Description |
---|---|
void |
addDependency(Refreshable refreshable)
Add a dependency to be refreshed first when the encapsulating object does.
|
static Collection<Refreshable> |
buildRefreshed(Collection<Refreshable> currentAlreadyRefreshed)
Creates a new and empty
Collection if the method parameter is null . |
static void |
maybeRefresh(Collection<Refreshable> alreadyRefreshed,
Refreshable refreshable)
Adds the specified
Refreshable to the given collection of Refreshable s if it is not
already there and immediately refreshes it. |
void |
refresh(Collection<Refreshable> alreadyRefreshed)
Typically this is called in
Refreshable.refresh(java.util.Collection) and is the entire body of
that method. |
void |
removeDependency(Refreshable refreshable) |
public RefreshHelper(Callable<?> refreshRunnable)
refreshRunnable
- encapsulates the containing object's own refresh logicpublic void addDependency(Refreshable refreshable)
public void removeDependency(Refreshable refreshable)
public void refresh(Collection<Refreshable> alreadyRefreshed)
Refreshable.refresh(java.util.Collection)
and is the entire body of
that method.refresh
in interface Refreshable
alreadyRefreshed
- Refreshable
s that are known to have already been
refreshed as a result of an initial call to a {#refresh(Collection)} method on some
object. This ensure that objects in a refresh dependency graph aren't refreshed twice
needlessly.public static Collection<Refreshable> buildRefreshed(Collection<Refreshable> currentAlreadyRefreshed)
Collection
if the method parameter is null
.currentAlreadyRefreshed
- Refreshable
s to refresh later onCollection
if the method param was null
or the unmodified method
param.public static void maybeRefresh(Collection<Refreshable> alreadyRefreshed, Refreshable refreshable)
Refreshable
to the given collection of Refreshable
s if it is not
already there and immediately refreshes it.alreadyRefreshed
- the collection of Refreshable
srefreshable
- the Refreshable
to potentially add and refreshCopyright © 2008–2017 The Apache Software Foundation. All rights reserved.