java.lang.Object
org.elasticsearch.common.unit.RatioValue
- All Implemented Interfaces:
Writeable
Utility class to represent ratio and percentage values between 0 and 100
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the percent as a string with no trailing zeros and the '%' suffix.double
double
static RatioValue
parseRatioValue
(String sValue) Parses the provided string as aRatioValue
, the string can either be in percentage format (eg.static RatioValue
readFrom
(StreamInput in) toString()
void
writeTo
(StreamOutput out) Write this into the StreamOutput.
-
Constructor Details
-
RatioValue
public RatioValue(double percent)
-
-
Method Details
-
getAsRatio
public double getAsRatio() -
getAsPercent
public double getAsPercent() -
toString
-
parseRatioValue
Parses the provided string as aRatioValue
, the string can either be in percentage format (eg. 73.5%), or a floating-point ratio format (eg. 0.735) -
formatNoTrailingZerosPercent
Returns the percent as a string with no trailing zeros and the '%' suffix. -
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
readFrom
- Throws:
IOException
-