Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.util;

A unit of size.
 
 public enum SizeUnit {
    
Bytes.
 
    BYTES(8),

    
Kilobytes.
    KILOBYTES(8L * 1024),

    
Megabytes.
    MEGABYTES(8L * 1024 * 1024),

    
Gigabytes.
    GIGABYTES(8L * 1024 * 1024 * 1024),

    
Megabytes.
    TERABYTES(8L * 1024 * 1024 * 1024 * 1024);
    private final long bits;
    SizeUnit(long bits) {
        this. = bits;
    }

    
Converts a size of the given unit into the current unit.

Parameters:
size the magnitude of the size
unit the unit of the size
Returns:
the given size in the current unit.
    public long convert(long sizeSizeUnit unit) {
        return (size * unit.bits) / ;
    }

    
Converts the given number of the current units into bytes.

Parameters:
l the magnitude of the size in the current unit
Returns:
l of the current units in bytes
    public long toBytes(long l) {
        return .convert(lthis);
    }

    
Converts the given number of the current units into kilobytes.

Parameters:
l the magnitude of the size in the current unit
Returns:
l of the current units in kilobytes
    public long toKilobytes(long l) {
        return .convert(lthis);
    }

    
Converts the given number of the current units into megabytes.

Parameters:
l the magnitude of the size in the current unit
Returns:
l of the current units in megabytes
    public long toMegabytes(long l) {
        return .convert(lthis);
    }

    
Converts the given number of the current units into gigabytes.

Parameters:
l the magnitude of the size in the current unit
Returns:
l of the current units in bytes
    public long toGigabytes(long l) {
        return .convert(lthis);
    }

    
Converts the given number of the current units into terabytes.

Parameters:
l the magnitude of the size in the current unit
Returns:
l of the current units in terabytes
    public long toTerabytes(long l) {
        return .convert(lthis);
    }
New to GrepCode? Check out our FAQ X