public double getStorageSize ( String name , String defaultValue , StorageUnit targetUnit ) { Preconditions . checkState ( isNotBlank ( name ) , "Key cannot be blank." ) ; String vString = get ( name ) ; if ( isBlank ( vString ) ) { vString = defaultValue ; } // Please note: There is a bit of subtlety here. If the user specifies // the default unit as "1GB", but the requested unit is MB, we will return // the format in MB even thought the default string is specified in GB. // Converts a string like "1GB" to to unit specified in targetUnit. StorageSize measure = StorageSize . parse ( vString ) ; return convertStorageUnit ( measure . getValue ( ) , measure . getUnit ( ) , targetUnit ) ; }
Gets the Storage Size from the config or returns the defaultValue . The unit of return value is specified in target unit .