/** * 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 stopwatch from the specified parent stopwatch with the specified task title. * * @param parent the specified parent * @param taskTitle the specified task title * @return stopwatch, returns {@code null} if not found */ private static Stopwatch get(final Stopwatch parent, final String taskTitle) { if (taskTitle.equals(parent.getTaskTitle())) { return parent; } for (final Stopwatch leaf : parent.getLeaves()) { final Stopwatch ret = get(leaf, taskTitle); if (null != ret) { return ret; } } return null; }
/** * 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 stopwatch from the specified parent stopwatch with the specified task title. * * @param parent the specified parent * @param taskTitle the specified task title * @return stopwatch, returns {@code null} if not found */ private static Stopwatch get(final Stopwatch parent, final String taskTitle) { if (taskTitle.equals(parent.getTaskTitle())) { return parent; } for (final Stopwatch leaf : parent.getLeaves()) { final Stopwatch ret = get(leaf, taskTitle); if (null != ret) { return ret; } } return null; }