diff --git a/spring-core/src/main/java/org/springframework/util/unit/DataSize.java b/spring-core/src/main/java/org/springframework/util/unit/DataSize.java index 52b6cb5f81a..a3ca20e56b9 100644 --- a/spring-core/src/main/java/org/springframework/util/unit/DataSize.java +++ b/spring-core/src/main/java/org/springframework/util/unit/DataSize.java @@ -26,10 +26,27 @@ import org.springframework.util.StringUtils; /** * A data size, such as '12MB'. * - *
This class models a size in terms of bytes and is immutable and thread-safe. + *
This class models data size in terms of bytes and is immutable and thread-safe. + * + *
The terms and units used in this class are based on + * binary prefixes + * indicating multiplication by powers of 2. Consult the following table and + * the Javadoc for {@link DataUnit} for details. + * + *
+ *
| Term | Data Size | Size in Bytes |
|---|---|---|
| byte | 1B | 1 |
| kilobyte | 1KB | 1,024 |
| megabyte | 1MB | 1,048,576 |
| gigabyte | 1GB | 1,073,741,824 |
| terabyte | 1TB | 1,099,511,627,776 |
* The string starts with a number followed optionally by a unit matching one of the - * supported {@link DataUnit suffixes}. + * supported {@linkplain DataUnit suffixes}. *
* Examples: *
diff --git a/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java b/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java
index dc00e2ded28..3ade6a289b0 100644
--- a/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java
+++ b/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,35 +19,52 @@ package org.springframework.util.unit;
import java.util.Objects;
/**
- * A standard set of data size units.
+ * A standard set of {@link DataSize} units.
+ *
+ * The unit prefixes used in this class are
+ * binary prefixes
+ * indicating multiplication by powers of 2. The following table displays the
+ * enum constants defined in this class and corresponding values.
+ *
+ *
+ *
| Constant | Data Size | Power of 2 | Size in Bytes |
|---|---|---|---|
| {@link #BYTES} | 1B | 2^0 | 1 |
| {@link #KILOBYTES} | 1KB | 2^10 | 1,024 |
| {@link #MEGABYTES} | 1MB | 2^20 | 1,048,576 |
| {@link #GIGABYTES} | 1GB | 2^30 | 1,073,741,824 |
| {@link #TERABYTES} | 1TB | 2^40 | 1,099,511,627,776 |