public class ReverseLookupListener extends LivenessArtifact implements ReverseLookup, DynamicNode
ReverseLookup.Null
Modifier and Type | Method and Description |
---|---|
void |
addParentReference(Object parent)
Called on a dependent node to ensure that a strong reference is maintained to any parent object that
is required for the proper maintenance and functioning of the dependent.
|
protected void |
destroy()
Attempt to release (destructively when necessary) resources held by this object.
|
void |
dropReference()
Drop a previously-retained reference to this referent.
|
void |
dumpReverseTable(com.fishlib.io.logger.Logger log) |
long |
get(Object key)
Gets the index value where key exists in the table, or the no-entry-value if it is not found in the table.
|
protected Object |
getKey(long row)
Gets the key for a given row.
|
String[] |
getKeyColumns() |
long |
getNoEntryValue()
Returns the value that will be returned from
ReverseLookup.get(java.lang.Object) or if no entry exists for a given key. |
long |
getPrev(Object key)
Gets the index value where key previously in the table, or the no-entry-value if it is was not found in the table.
|
WeakReference<? extends LivenessReferent> |
getWeakReference()
Get a
WeakReference to this referent. |
void |
initializeTransientFieldsForLiveness()
Package-private for
Serializable sub-classes to use in readObject only. |
boolean |
isRefreshing()
Is the node updating?
|
static ReverseLookupListener |
makeReverseLookupListenerWithLock(DynamicTable source,
String... columns) |
static ReverseLookupListener |
makeReverseLookupListenerWithSnapshot(BaseTable source,
String... columns) |
protected void |
onReferenceCountAtZero()
Callback method that will be invoked when the reference count returns to zero.
|
static void |
prepareForTree(BaseTable preTree,
String idColumn)
Prepare the parameter table for use with
tree table |
boolean |
setRefreshing(boolean refreshing)
Change the node's refresh mode.
|
String |
toString() |
boolean |
tryManage(LivenessReferent referent)
Attempt to add the specified referent to this manager.
|
boolean |
tryRetainReference()
If this referent is "live", behave as
LivenessReferent.retainReference() and return true. |
manageWithCurrentScope, unmanage, unmanage
append, decrementReferenceCount, incrementReferenceCount, resetReferenceCount, tryDecrementReferenceCount, tryIncrementReferenceCount
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isDynamicAndIsRefreshing, isDynamicAndNotRefreshing, notDynamicOrIsRefreshing, notDynamicOrNotRefreshing
getReferentDescription, retainReference
manage
public static ReverseLookupListener makeReverseLookupListenerWithSnapshot(BaseTable source, String... columns)
public static ReverseLookupListener makeReverseLookupListenerWithLock(DynamicTable source, String... columns)
@ScriptApi public static void prepareForTree(BaseTable preTree, String idColumn)
tree table
preTree
- The tree to prepareidColumn
- The column that will be used as the id for Table.treeTable(String, String)
public long get(Object key)
ReverseLookup
get
in interface ReverseLookup
key
- a single object for a single column, or a SmartKey
for multiple columnspublic long getPrev(Object key)
ReverseLookup
getPrev
in interface ReverseLookup
key
- a single object for a single column, or a SmartKey
for multiple columnspublic long getNoEntryValue()
ReverseLookup
ReverseLookup.get(java.lang.Object)
or if no entry exists for a given key.getNoEntryValue
in interface ReverseLookup
protected Object getKey(long row)
row
- the index value to retrieve the key forpublic String toString()
toString
in class ReferenceCounted
public void dumpReverseTable(com.fishlib.io.logger.Logger log)
dumpReverseTable
in interface ReverseLookup
public String[] getKeyColumns()
getKeyColumns
in interface ReverseLookup
public boolean isRefreshing()
DynamicNode
isRefreshing
in interface DynamicNode
public boolean setRefreshing(boolean refreshing)
DynamicNode
setRefreshing
in interface DynamicNode
refreshing
- true to cause the node to update; false otherwise.public void addParentReference(Object parent)
DynamicNode
addParentReference
in interface DynamicNode
parent
- A parent of this node@VisibleForTesting public final void initializeTransientFieldsForLiveness()
Serializable
sub-classes to use in readObject
only.
Public to allow unit tests in another package to work around mock issues where the constructor is never invoked.public final boolean tryRetainReference()
LivenessReferent
LivenessReferent.retainReference()
and return true.
Otherwise, returns false rather than throwing an exception.tryRetainReference
in interface LivenessReferent
public final void dropReference()
LivenessReferent
dropReference
in interface LivenessReferent
public WeakReference<? extends LivenessReferent> getWeakReference()
LivenessReferent
WeakReference
to this referent. This may be cached, or newly created.getWeakReference
in interface LivenessReferent
public final boolean tryManage(@NotNull LivenessReferent referent)
LivenessManager
tryManage
in interface LivenessManager
referent
- The referent to addprotected void destroy()
Attempt to release (destructively when necessary) resources held by this object. This may render the object unusable for subsequent operations. Implementations should be sure to call super.destroy().
This is intended to only ever be used as a side effect of decreasing the reference count to 0.
protected final void onReferenceCountAtZero()
ReferenceCounted
onReferenceCountAtZero
in class ReferenceCounted