Class Threshold

java.lang.Object
org.jboss.resteasy.spi.config.Threshold

public class Threshold extends Object
Represents a threshold for a unit size.
Author:
James R. Perkins
  • Field Details

    • NONE

      public static final Threshold NONE
    • DEFAULT

      public static final Threshold DEFAULT
  • Method Details

    • of

      public static Threshold of(long size, SizeUnit unit)
      Creates a new threshold.

      If the size is less than 0, then the NONE instance is returned regardless of the unit.

      Parameters:
      size - the maximum size of the threshold
      unit - the unit of measurement to calculate the size in bytes
    • toBytes

      public long toBytes()
      The size in bytes for this threshold.
      Returns:
      the size in bytes
    • sizeUnit

      public SizeUnit sizeUnit()
      Returns the size unit for this threshold.
      Returns:
      the size unit
    • reached

      public boolean reached(long size)
      Checks if the given size is greater than the bytes available for the threshold.
      Parameters:
      size - the size to validate
      Returns:
      false if the size is greater than the bytes allowed for this threshold, otherwise true
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • valueOf

      public static Threshold valueOf(String value)
      Parses the given string representation of a threshold. For example a value of "1MB" would return a threshold with a size of 1 megabyte.
      Parameters:
      value - the value to parse
      Returns:
      a threshold based on the parsed string
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object