/** * Gets the recent running stopwatch with the specified parent stopwatch. * * @param parent the specified parent stopwatch * @return the recent stopwatch, returns {@code null} if not found */ private static Stopwatch getRecentRunning(final Stopwatch parent) { if (null == parent) { return null; } final List<Stopwatch> leaves = parent.getLeaves(); if (leaves.isEmpty()) { if (parent.isRunning()) { return parent; } else { return null; } } for (int i = leaves.size() - 1; i > -1; i--) { final Stopwatch leaf = leaves.get(i); if (leaf.isRunning()) { return getRecentRunning(leaf); } else { continue; } } return parent; }
/** * Gets the recent running stopwatch with the specified parent stopwatch. * * @param parent the specified parent stopwatch * @return the recent stopwatch, returns {@code null} if not found */ private static Stopwatch getRecentRunning(final Stopwatch parent) { if (null == parent) { return null; } final List<Stopwatch> leaves = parent.getLeaves(); if (leaves.isEmpty()) { if (parent.isRunning()) { return parent; } else { return null; } } for (int i = leaves.size() - 1; i > -1; i--) { final Stopwatch leaf = leaves.get(i); if (leaf.isRunning()) { return getRecentRunning(leaf); } else { continue; } } return parent; }