public final class ParentChainTracker
Detects cycles in a parent-object chain (e.g. a Web test object's parent-iframe ref_element chain) via
raw string equality - no id-normalization (no "Object Repository/"-prefix stripping) is applied.
Callers MUST supply ids drawn from a single consistent id-space for the entire call chain (e.g. all
WebElementEntity.getIdForDisplay() ids, or all ObjectRepository-normalized test object ids).
Mixing id formats within one chain can cause both false negatives (a real loop not detected) and false
positives (a non-loop wrongly flagged).
Internal helper, not part of the scripting API.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static List<String> |
append(List<String> chainSoFar, String nextObjectId)Appends nextObjectId to chainSoFar, throwing if it already appears in the chain. |
|
public static void |
ensureNoLoopThrough(String startId, String startParentId, UnaryOperator<String> parentIdLookup)Refuses a write that would make an object its own ancestor. |
Appends nextObjectId to chainSoFar, throwing if it already appears in the chain.
nextObjectId already appears in chainSoFarchainSoFar - the ids visited so far, in visit order, all from the same id-spacenextObjectId - the next id being visited, from the SAME id-space as chainSoFarnextObjectId appendedRefuses a write that would make an object its own ancestor.
Starting at startId, follows the parent chain (first hop startParentId, every later hop
parentIdLookup) and throws when the chain returns to startId. A loop that does NOT contain
startId (the object merely leads into someone else's loop) is not an error here: it terminates because
every hop either adds a new id or ends the walk.
All ids (start, first hop, lookup results) MUST come from one id-space, see the class comment.
Internal helper, not part of the scripting API.
startId; the loop list starts and ends
with startIdstartId is null or blankstartId - id of the object being written, must not be null or blankstartParentId - id of the parent the object will have after the write; null or blank means no parentparentIdLookup - returns the parent id of the object with the given id, or null/blank when it has none or
cannot be resolved (a dangling reference ends the chain)