At the moment the constants in org.springframework.util.unit.DataSize
are private
and cannot be used, for example, in annotations, so we have to bloat our code with 1024
everywhere.
Thanks.
Comment From: sbrannen
Hi @albertus82,
Those constants in DataSize
are intentionally private because they represent an internal implementation detail.
One normally uses one of the static parse(...)
methods in DataSize
to parse a data size string, and DataSize.parse(CharSequence, DataUnit)
accepts a DataUnit
in case you need to specify one.
Note that Spring Boot also has built-in support for converting application properties to DataSize
values. See Converting Data Sizes for details.
At the moment the constants in
org.springframework.util.unit.DataSize
areprivate
and cannot be used, for example, in annotations, so we have to bloat our code with1024
everywhere.
Can you please provide concrete examples of how you are using DataSize
?
For example, which annotations are you talking about?
Cheers,
Sam
Comment From: albertus82
Hi @sbrannen,
Those constants in
DataSize
are intentionally private because they represent an internal implementation detail.
Commons IO contains something similar in its org.apache.commons.io.FileUtils
class.
IMHO those constants are actually only some specific powers of two. You might reword them before making them public if their name represent an implementation detail (and maybe keep the private ones referencing the public ones).
For example, which annotations are you talking about?
e.g. @jakarta.validation.constraints.Size
(on arrays).
Thanks.