Enum Class ByteUnit

java.lang.Object
java.lang.Enum<ByteUnit>
com.iland.core.api.util.ByteUnit
All Implemented Interfaces:
Serializable, Comparable<ByteUnit>, Constable

public enum ByteUnit extends Enum<ByteUnit>
Units of bytes.
  • Enum Constant Details

    • B

      public static final ByteUnit B
    • KB

      public static final ByteUnit KB
      Kilobyte.
    • KiB

      public static final ByteUnit KiB
      Kibibyte.
    • MB

      public static final ByteUnit MB
      Megabyte.
    • MiB

      public static final ByteUnit MiB
      Mebibyte.
    • GB

      public static final ByteUnit GB
      Gigabyte.
    • GiB

      public static final ByteUnit GiB
      Gibibyte.
    • TB

      public static final ByteUnit TB
      Terabyte.
    • TiB

      public static final ByteUnit TiB
      Tebibyte.
    • PB

      public static final ByteUnit PB
      Petabyte.
    • PiB

      public static final ByteUnit PiB
      Pebibyte.
  • Method Details

    • values

      public static ByteUnit[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ByteUnit valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • toBytes

      public long toBytes()
      Returns:
      the value measured in bytes
    • toBytes

      public long toBytes(long amount)
      Returns:
      the value measured in bytes
    • fromValue

      public static Optional<ByteUnit> fromValue(String name)
    • toString

      public static String toString(long bytes)
      Convert bytes to human-readable string.
      Parameters:
      bytes - the number of bytes
      Returns:
      the formatted number of bytes