Class RatioValue

java.lang.Object
org.elasticsearch.common.unit.RatioValue
All Implemented Interfaces:
Writeable

public class RatioValue extends Object implements Writeable
Utility class to represent ratio and percentage values between 0 and 100
  • Constructor Details

    • RatioValue

      public RatioValue(double percent)
  • Method Details

    • getAsRatio

      public double getAsRatio()
    • getAsPercent

      public double getAsPercent()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parseRatioValue

      public static RatioValue parseRatioValue(String sValue)
      Parses the provided string as a RatioValue, the string can either be in percentage format (eg. 73.5%), or a floating-point ratio format (eg. 0.735)
    • formatNoTrailingZerosPercent

      public String formatNoTrailingZerosPercent()
      Returns the percent as a string with no trailing zeros and the '%' suffix.
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • readFrom

      public static RatioValue readFrom(StreamInput in) throws IOException
      Throws:
      IOException