Skip to content

Instantly share code, notes, and snippets.

@bivas
Created December 1, 2013 22:28
Show Gist options
  • Save bivas/7741708 to your computer and use it in GitHub Desktop.
Save bivas/7741708 to your computer and use it in GitHub Desktop.
Helpful utility for transforming size units from/to. - Inspired by java.util.concurrent.TimeUnit Official definitions from http://en.wikipedia.org/wiki/Binary_prefix
package iam.bivas.commons.bytes;
public enum ByteUnit {
BYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toBytes(amount); }
@Override public double toBytes(double amount) { return amount; }
@Override public double toKilobytes(double amount) { return amount / DK; }
@Override public double toKibibytes(double amount) { return amount / BK; }
@Override public double toMegabytes(double amount) { return toKilobytes(amount) / DK; }
@Override public double toMebibytes(double amount) { return toKibibytes(amount) / BK; }
@Override public double toGigabytes(double amount) { return toMegabytes(amount) / DK; }
@Override public double toGibibytes(double amount) { return toMebibytes(amount) / BK; }
@Override public double toTerabytes(double amount) { return toGigabytes(amount) / DK; }
@Override public double toTebibytes(double amount) { return toGibibytes(amount) / BK; }
@Override public double toPetabytes(double amount) { return toTerabytes(amount) / DK; }
@Override public double toPebibytes(double amount) { return toTebibytes(amount) / BK; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
KILOBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toKilobytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return amount; }
@Override public double toKibibytes(double amount) { return amount / R; }
@Override public double toMegabytes(double amount) { return toKilobytes(amount) / DK; }
@Override public double toMebibytes(double amount) { return toKibibytes(amount) / BK; }
@Override public double toGigabytes(double amount) { return toMegabytes(amount) / DK; }
@Override public double toGibibytes(double amount) { return toMebibytes(amount) / BK; }
@Override public double toTerabytes(double amount) { return toGigabytes(amount) / DK; }
@Override public double toTebibytes(double amount) { return toGibibytes(amount) / BK; }
@Override public double toPetabytes(double amount) { return toTerabytes(amount) / DK; }
@Override public double toPebibytes(double amount) { return toTebibytes(amount) / BK; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
KIBIBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toKibibytes(amount); }
@Override public double toBytes(double amount) { return toKibibytes(amount) * BK; }
@Override public double toKilobytes(double amount) { return amount * R; }
@Override public double toKibibytes(double amount) { return amount; }
@Override public double toMegabytes(double amount) { return toKilobytes(amount) / DK; }
@Override public double toMebibytes(double amount) { return toKibibytes(amount) / BK; }
@Override public double toGigabytes(double amount) { return toMegabytes(amount) / DK; }
@Override public double toGibibytes(double amount) { return toMebibytes(amount) / BK; }
@Override public double toTerabytes(double amount) { return toGigabytes(amount) / DK; }
@Override public double toTebibytes(double amount) { return toGibibytes(amount) / BK; }
@Override public double toPetabytes(double amount) { return toTerabytes(amount) / DK; }
@Override public double toPebibytes(double amount) { return toTebibytes(amount) / BK; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
MEGABYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toMegabytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return amount; }
@Override public double toMebibytes(double amount) { return amount / R; }
@Override public double toGigabytes(double amount) { return toMegabytes(amount) / DK; }
@Override public double toGibibytes(double amount) { return toMebibytes(amount) / BK; }
@Override public double toTerabytes(double amount) { return toGigabytes(amount) / DK; }
@Override public double toTebibytes(double amount) { return toGibibytes(amount) / BK; }
@Override public double toPetabytes(double amount) { return toTerabytes(amount) / DK; }
@Override public double toPebibytes(double amount) { return toTebibytes(amount) / BK; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
MEBIBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toMebibytes(amount); }
@Override public double toBytes(double amount) { return toKibibytes(amount) * BK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return amount; }
@Override public double toMebibytes(double amount) { return amount / R; }
@Override public double toGigabytes(double amount) { return toMegabytes(amount) / DK; }
@Override public double toGibibytes(double amount) { return toMebibytes(amount) / BK; }
@Override public double toTerabytes(double amount) { return toGigabytes(amount) / DK; }
@Override public double toTebibytes(double amount) { return toGibibytes(amount) / BK; }
@Override public double toPetabytes(double amount) { return toTerabytes(amount) / DK; }
@Override public double toPebibytes(double amount) { return toTebibytes(amount) / BK; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
GIGABYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toGigabytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return amount; }
@Override public double toGibibytes(double amount) { return amount / R; }
@Override public double toTerabytes(double amount) { return toGigabytes(amount) / DK; }
@Override public double toTebibytes(double amount) { return toGibibytes(amount) / BK; }
@Override public double toPetabytes(double amount) { return toTerabytes(amount) / DK; }
@Override public double toPebibytes(double amount) { return toTebibytes(amount) / BK; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
GIBIBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toGibibytes(amount); }
@Override public double toBytes(double amount) { return toKibibytes(amount) * BK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return amount * R; }
@Override public double toGibibytes(double amount) { return amount; }
@Override public double toTerabytes(double amount) { return toGigabytes(amount) / DK; }
@Override public double toTebibytes(double amount) { return toGibibytes(amount) / BK; }
@Override public double toPetabytes(double amount) { return toTerabytes(amount) / DK; }
@Override public double toPebibytes(double amount) { return toTebibytes(amount) / BK; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
TERABYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toTerabytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return amount; }
@Override public double toTebibytes(double amount) { return amount / R; }
@Override public double toPetabytes(double amount) { return toTerabytes(amount) / DK; }
@Override public double toPebibytes(double amount) { return toTebibytes(amount) / BK; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
TEBIBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toTebibytes(amount); }
@Override public double toBytes(double amount) { return toKibibytes(amount) * BK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return amount * R; }
@Override public double toTebibytes(double amount) { return amount; }
@Override public double toPetabytes(double amount) { return toTerabytes(amount) / DK; }
@Override public double toPebibytes(double amount) { return toTebibytes(amount) / BK; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
PETABYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toPetabytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return amount; }
@Override public double toPebibytes(double amount) { return amount / R; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
PEBIBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toPebibytes(amount); }
@Override public double toBytes(double amount) { return toKibibytes(amount) * BK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return amount * R; }
@Override public double toPebibytes(double amount) { return amount; }
@Override public double toExabytes(double amount) { return toPetabytes(amount) / DK; }
@Override public double toExbibytes(double amount) { return toPebibytes(amount) / BK; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
EXABYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toExabytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return toExabytes(amount) * DK; }
@Override public double toPebibytes(double amount) { return toExbibytes(amount) * BK; }
@Override public double toExabytes(double amount) { return amount; }
@Override public double toExbibytes(double amount) { return amount / R; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
EXBIBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toExbibytes(amount); }
@Override public double toBytes(double amount) { return toKibibytes(amount) * BK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return toExabytes(amount) * DK; }
@Override public double toPebibytes(double amount) { return toExbibytes(amount) * BK; }
@Override public double toExabytes(double amount) { return amount * R; }
@Override public double toExbibytes(double amount) { return amount; }
@Override public double toZettabytes(double amount) { return toExabytes(amount) / DK; }
@Override public double toZebibytes(double amount) { return toExbibytes(amount) / BK; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
ZETTABYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toZettabytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return toExabytes(amount) * DK; }
@Override public double toPebibytes(double amount) { return toExbibytes(amount) * BK; }
@Override public double toExabytes(double amount) { return toZettabytes(amount) * DK; }
@Override public double toExbibytes(double amount) { return toZebibytes(amount) * BK; }
@Override public double toZettabytes(double amount) { return amount; }
@Override public double toZebibytes(double amount) { return amount / R; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
ZEBIBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toZebibytes(amount); }
@Override public double toBytes(double amount) { return toKibibytes(amount) * BK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return toExabytes(amount) * DK; }
@Override public double toPebibytes(double amount) { return toExbibytes(amount) * BK; }
@Override public double toExabytes(double amount) { return toZettabytes(amount) * DK; }
@Override public double toExbibytes(double amount) { return toZebibytes(amount) * BK; }
@Override public double toZettabytes(double amount) { return amount * R; }
@Override public double toZebibytes(double amount) { return amount; }
@Override public double toYottabytes(double amount) { return toZettabytes(amount) / DK; }
@Override public double toYobibytes(double amount) { return toZebibytes(amount) / BK; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
YOTTABYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toYottabytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return toExabytes(amount) * DK; }
@Override public double toPebibytes(double amount) { return toExbibytes(amount) * BK; }
@Override public double toExabytes(double amount) { return toZettabytes(amount) * DK; }
@Override public double toExbibytes(double amount) { return toZebibytes(amount) * BK; }
@Override public double toZettabytes(double amount) { return toYottabytes(amount) * DK; }
@Override public double toZebibytes(double amount) { return toYobibytes(amount) * BK; }
@Override public double toYottabytes(double amount) { return amount; }
@Override public double toYobibytes(double amount) { return amount / R; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
YOBIBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toYobibytes(amount); }
@Override public double toBytes(double amount) { return toKibibytes(amount) * BK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return toExabytes(amount) * DK; }
@Override public double toPebibytes(double amount) { return toExbibytes(amount) * BK; }
@Override public double toExabytes(double amount) { return toZettabytes(amount) * DK; }
@Override public double toExbibytes(double amount) { return toZebibytes(amount) * BK; }
@Override public double toZettabytes(double amount) { return toYottabytes(amount) * DK; }
@Override public double toZebibytes(double amount) { return toYobibytes(amount) * BK; }
@Override public double toYottabytes(double amount) { return amount * R; }
@Override public double toYobibytes(double amount) { return amount; }
@Override public double toXenottabytes(double amount) { return toYottabytes(amount) / DK; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
XENOTTABYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toXenottabytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return toExabytes(amount) * DK; }
@Override public double toPebibytes(double amount) { return toExbibytes(amount) * BK; }
@Override public double toExabytes(double amount) { return toZettabytes(amount) * DK; }
@Override public double toExbibytes(double amount) { return toZebibytes(amount) * BK; }
@Override public double toZettabytes(double amount) { return toYottabytes(amount) * DK; }
@Override public double toZebibytes(double amount) { return toYobibytes(amount) * BK; }
@Override public double toYottabytes(double amount) { return toXenottabytes(amount) * DK; }
@Override public double toYobibytes(double amount) { return toXenottabytes(amount) * BK / R; }
@Override public double toXenottabytes(double amount) { return amount; }
@Override public double toShilentnobytes(double amount) { return toXenottabytes(amount) / DK; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
SHILENTNOBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toShilentnobytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return toExabytes(amount) * DK; }
@Override public double toPebibytes(double amount) { return toExbibytes(amount) * BK; }
@Override public double toExabytes(double amount) { return toZettabytes(amount) * DK; }
@Override public double toExbibytes(double amount) { return toZebibytes(amount) * BK; }
@Override public double toZettabytes(double amount) { return toYottabytes(amount) * DK; }
@Override public double toZebibytes(double amount) { return toYobibytes(amount) * BK; }
@Override public double toYottabytes(double amount) { return toXenottabytes(amount) * DK; }
@Override public double toYobibytes(double amount) { return toXenottabytes(amount) * BK / R; }
@Override public double toXenottabytes(double amount) { return toShilentnobytes(amount) * BK / R; }
@Override public double toShilentnobytes(double amount) { return amount; }
@Override public double toDomegemegrottebytes(double amount) { return toShilentnobytes(amount) / DK; }
},
DOMEGEMEGROTTEBYTES {
@Override public double convert(double amount, ByteUnit unit) { return unit.toDomegemegrottebytes(amount); }
@Override public double toBytes(double amount) { return toKilobytes(amount) * DK; }
@Override public double toKilobytes(double amount) { return toMegabytes(amount) * DK; }
@Override public double toKibibytes(double amount) { return toMebibytes(amount) * BK; }
@Override public double toMegabytes(double amount) { return toGigabytes(amount) * DK; }
@Override public double toMebibytes(double amount) { return toGibibytes(amount) * BK; }
@Override public double toGigabytes(double amount) { return toTerabytes(amount) * DK; }
@Override public double toGibibytes(double amount) { return toTebibytes(amount) * BK; }
@Override public double toTerabytes(double amount) { return toPetabytes(amount) * DK; }
@Override public double toTebibytes(double amount) { return toPebibytes(amount) * BK; }
@Override public double toPetabytes(double amount) { return toExabytes(amount) * DK; }
@Override public double toPebibytes(double amount) { return toExbibytes(amount) * BK; }
@Override public double toExabytes(double amount) { return toZettabytes(amount) * DK; }
@Override public double toExbibytes(double amount) { return toZebibytes(amount) * BK; }
@Override public double toZettabytes(double amount) { return toYottabytes(amount) * DK; }
@Override public double toZebibytes(double amount) { return toYobibytes(amount) * BK; }
@Override public double toYottabytes(double amount) { return toXenottabytes(amount) * DK; }
@Override public double toYobibytes(double amount) { return toXenottabytes(amount) * BK / R; }
@Override public double toXenottabytes(double amount) { return toShilentnobytes(amount) * BK / R; }
@Override public double toShilentnobytes(double amount) { return toDomegemegrottebytes(amount) * BK / R; }
@Override public double toDomegemegrottebytes(double amount) { return amount; }
};
// Decimal Kilo
private static final double DK = 1000.0;
// Binary Kilo
private static final double BK = 1024.0;
private static final double R = BK / DK;
public double convert(double amount, ByteUnit unit) { throw new AbstractMethodError(); }
public double toBytes(double amount) { throw new AbstractMethodError(); }
public double toKilobytes(double amount) { throw new AbstractMethodError(); }
public double toKibibytes(double amount) { throw new AbstractMethodError(); }
public double toMegabytes(double amount) { throw new AbstractMethodError(); }
public double toMebibytes(double amount) { throw new AbstractMethodError(); }
public double toGigabytes(double amount) { throw new AbstractMethodError(); }
public double toGibibytes(double amount) { throw new AbstractMethodError(); }
public double toTerabytes(double amount) { throw new AbstractMethodError(); }
public double toTebibytes(double amount) { throw new AbstractMethodError(); }
public double toPetabytes(double amount) { throw new AbstractMethodError(); }
public double toPebibytes(double amount) { throw new AbstractMethodError(); }
public double toExabytes(double amount) { throw new AbstractMethodError(); }
public double toExbibytes(double amount) { throw new AbstractMethodError(); }
public double toZettabytes(double amount) { throw new AbstractMethodError(); }
public double toZebibytes(double amount) { throw new AbstractMethodError(); }
public double toYottabytes(double amount) { throw new AbstractMethodError(); }
public double toYobibytes(double amount) { throw new AbstractMethodError(); }
public double toXenottabytes(double amount) { throw new AbstractMethodError(); }
public double toShilentnobytes(double amount) { throw new AbstractMethodError(); }
public double toDomegemegrottebytes(double amount) { throw new AbstractMethodError(); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment