com.twitter.common.quantity
Enum Data

java.lang.Object
  extended by java.lang.Enum<Data>
      extended by com.twitter.common.quantity.Data
All Implemented Interfaces:
Unit<Data>, Serializable, Comparable<Data>

public enum Data
extends Enum<Data>
implements Unit<Data>

Provides a unit to allow conversions and unambiguous passing around of data Amounts. The kilo/mega/giga/... hierarchy is built on base 2 so that the hierarchy increases by a factor of 1024 instead of 1000 as typical in metric units. Additionally, units are divided in 2 hierarchies one based on bits and the other on bytes. Thus Kb represents kilobits; so 1 Kb = 1024 bits, and KB represents kilobytes so 1 KB = 1024 bytes or 8192 bits.


Enum Constant Summary
BITS
           
BYTES
           
Gb
           
GB
           
Kb
           
KB
           
Mb
           
MB
           
PB
           
TB
           
 
Method Summary
 double multiplier()
          Returns the weight of this unit relative to other units in the same hierarchy.
static Data valueOf(String name)
          Returns the enum constant of this type with the specified name.
static Data[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

BITS

public static final Data BITS

Kb

public static final Data Kb

Mb

public static final Data Mb

Gb

public static final Data Gb

BYTES

public static final Data BYTES

KB

public static final Data KB

MB

public static final Data MB

GB

public static final Data GB

TB

public static final Data TB

PB

public static final Data PB
Method Detail

values

public static Data[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Data c : Data.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Data valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
NullPointerException - if the argument is null

multiplier

public double multiplier()
Description copied from interface: Unit
Returns the weight of this unit relative to other units in the same hierarchy. Typically the smallest unit in the hierarchy returns 1, but this need not be the case. It is only required that each unit of the hierarchy return a multiplier relative to a common base unit for the hierarchy.

Specified by:
multiplier in interface Unit<Data>