private void stop() { if (!running) { throw new IllegalStateException(String .format("Cannot stop <%s>, since it is not running", id)); } final Instant stop = Instant.now(); final Duration runTime = Duration.between(start, stop); totalDuration = totalDuration.plus(runTime); final TaskInfo lastTaskInfo = new TaskInfo(currentTaskName, runTime); tasks.add(lastTaskInfo); running = false; currentTaskName = null; start = null; }
/** * Allows for a deferred conversion to a string. Useful in logging. * * @return String supplier. */ public Supplier<String> stringify() { return () -> { final StringBuilder buffer = new StringBuilder(1024); final LocalTime totalDurationLocal = LocalTime .ofNanoOfDay(totalDuration.toNanos()); buffer.append(String.format("Total time taken for <%s> - %s hours%n", id, totalDurationLocal.format(df))); for (final TaskInfo task: tasks) { buffer.append(String.format("-%5.1f%% - %s%n", calculatePercentage(task.getDuration(), totalDuration), task)); } return buffer.toString(); }; }
/** * Allows for a deferred conversion to a string. Useful in logging. * * @return String supplier. */ public Supplier<String> stringify() { return () -> { final StringBuilder buffer = new StringBuilder(1024); final LocalTime totalDurationLocal = LocalTime .ofNanoOfDay(totalDuration.toNanos()); buffer.append(String.format("Total time taken for <%s> - %s hours%n", id, totalDurationLocal.format(df))); for (final TaskInfo task: tasks) { buffer.append(String.format("-%5.1f%% - %s%n", calculatePercentage(task.getDuration(), totalDuration), task)); } return buffer.toString(); }; }
/** * Allows for a deferred conversion to a string. Useful in logging. * * @return String supplier. */ public Supplier<String> stringify() { return () -> { final StringBuilder buffer = new StringBuilder(1024); final LocalTime totalDurationLocal = LocalTime .ofNanoOfDay(totalDuration.toNanos()); buffer.append(String.format("Total time taken for <%s> - %s hours%n", id, totalDurationLocal.format(df))); for (final TaskInfo task: tasks) { buffer.append(String.format("-%5.1f%% - %s%n", calculatePercentage(task.getDuration(), totalDuration), task)); } return buffer.toString(); }; }
private void stop() { if (!running) { throw new IllegalStateException(String .format("Cannot stop <%s>, since it is not running", id)); } final Instant stop = Instant.now(); final Duration runTime = Duration.between(start, stop); totalDuration = totalDuration.plus(runTime); final TaskInfo lastTaskInfo = new TaskInfo(currentTaskName, runTime); tasks.add(lastTaskInfo); running = false; currentTaskName = null; start = null; }
private void stop() { if (!running) { throw new IllegalStateException(String .format("Cannot stop <%s>, since it is not running", id)); } final Instant stop = Instant.now(); final Duration runTime = Duration.between(start, stop); totalDuration = totalDuration.plus(runTime); final TaskInfo lastTaskInfo = new TaskInfo(currentTaskName, runTime); tasks.add(lastTaskInfo); running = false; currentTaskName = null; start = null; }
/** * Allows for a deferred conversion to a string. Useful in logging. * * @return String supplier. */ public Supplier<String> stringify() { return () -> { final StringBuilder buffer = new StringBuilder(1024); final LocalTime totalDurationLocal = LocalTime .ofNanoOfDay(totalDuration.toNanos()); buffer.append(String.format("Total time taken for <%s> - %s hours%n", id, totalDurationLocal.format(df))); for (final TaskInfo task: tasks) { buffer.append(String.format("-%5.1f%% - %s%n", calculatePercentage(task.getDuration(), totalDuration), task)); } return buffer.toString(); }; }
private void stop() { if (!running) { throw new IllegalStateException(String .format("Cannot stop <%s>, since it is not running", id)); } final Instant stop = Instant.now(); final Duration runTime = Duration.between(start, stop); totalDuration = totalDuration.plus(runTime); final TaskInfo lastTaskInfo = new TaskInfo(currentTaskName, runTime); tasks.add(lastTaskInfo); running = false; currentTaskName = null; start = null; }