Home / Class/ ProgressUpdateEvent Class — spring-boot Architecture

ProgressUpdateEvent Class — spring-boot Architecture

Architecture documentation for the ProgressUpdateEvent class in ProgressUpdateEvent.java from the spring-boot codebase.

Entity Profile

Source Code

buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/ProgressUpdateEvent.java lines 29–102

public abstract class ProgressUpdateEvent extends UpdateEvent {

	private final @Nullable String status;

	private final @Nullable ProgressDetail progressDetail;

	private final @Nullable String progress;

	protected ProgressUpdateEvent(@Nullable String status, @Nullable ProgressDetail progressDetail,
			@Nullable String progress) {
		this.status = status;
		this.progressDetail = (ProgressDetail.isEmpty(progressDetail)) ? null : progressDetail;
		this.progress = progress;
	}

	/**
	 * Return the status for the update. For example, "Extracting" or "Downloading".
	 * @return the status of the update.
	 */
	public @Nullable String getStatus() {
		return this.status;
	}

	/**
	 * Return progress details if available.
	 * @return progress details or {@code null}
	 */
	public @Nullable ProgressDetail getProgressDetail() {
		return this.progressDetail;
	}

	/**
	 * Return a text based progress bar if progress information is available.
	 * @return the progress bar or {@code null}
	 */
	public @Nullable String getProgress() {
		return this.progress;
	}

	/**
	 * Provide details about the progress of a task.
	 */
	public static class ProgressDetail {

		private final @Nullable Long current;

		private final @Nullable Long total;

		@JsonCreator
		public ProgressDetail(@Nullable Long current, @Nullable Long total) {
			this.current = current;
			this.total = total;
		}

		/**
		 * Return the progress as a percentage.
		 * @return the progress percentage
		 * @since 3.3.7
		 */
		public int asPercentage() {
			if (this.total == null || this.current == null) {
				return 0;
			}
			int percentage = (int) ((100.0 / this.total) * this.current);
			return (percentage < 0) ? 0 : Math.min(percentage, 100);
		}

		private static boolean isEmpty(@Nullable ProgressDetail progressDetail) {
			return progressDetail == null || progressDetail.current == null || progressDetail.total == null;
		}

	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free