枚举 DataUnit
- java.lang.Object
- java.lang.Enum<DataUnit>
- org.springframework.util.unit.DataUnit
- 所有已实现的接口:
Serializable,Comparable<DataUnit>
public enum DataUnit extends Enum<DataUnit>
A standard set ofDataSizeunits.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 BYTES1B 2^0 1 KILOBYTES1KB 2^10 1,024 MEGABYTES1MB 2^20 1,048,576 GIGABYTES1GB 2^30 1,073,741,824 TERABYTES1TB 2^40 1,099,511,627,776 - 从以下版本开始:
- 5.1
- 作者:
- Stephane Nicoll, Sam Brannen
- 另请参阅:
DataSize
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static DataUnitfromSuffix(String suffix)Return theDataUnitmatching the specifiedsuffix.static DataUnitvalueOf(String name)返回带有指定名称的该类型的枚举常量。static DataUnit[]values()按照声明该枚举类型的常量的顺序, 返回 包含这些常量的数组。
方法详细资料
values
public static DataUnit[] values()
按照声明该枚举类型的常量的顺序, 返回 包含这些常量的数组。该方法可用于迭代 常量, 如下所示:for (DataUnit c : DataUnit.values()) System.out.println(c);
- 返回:
- 按照声明该枚举类型的常量的顺序返回的包含这些常量的数组
valueOf
public static DataUnit valueOf(String name)
返回带有指定名称的该类型的枚举常量。 字符串必须与用于声明该类型的枚举常量的 标识符完全匹配。(不允许有多余 的空格字符。)- 参数:
name- 要返回的枚举常量的名称。- 返回:
- 返回带有指定名称的枚举常量
- 抛出:
IllegalArgumentException- 如果该枚举类型没有带有指定名称的常量NullPointerException- 如果参数为空值
fromSuffix
public static DataUnit fromSuffix(String suffix)
Return theDataUnitmatching the specifiedsuffix.- 参数:
suffix- one of the standard suffixes- 返回:
- the
DataUnitmatching the specifiedsuffix - 抛出:
IllegalArgumentException- if the suffix does not match the suffix of any of this enum's constants