Package org.jboss.resteasy.spi.config
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)inthashCode()static Thresholdof(long size, SizeUnit unit)Creates a new threshold.booleanreached(long size)Checks if the given size is greater than the bytes available for the threshold.SizeUnitsizeUnit()Returns the size unit for this threshold.longtoBytes()The size in bytes for this threshold.StringtoString()static ThresholdvalueOf(String value)Parses the given string representation of a threshold.
-
-
-
Method Detail
-
of
public static Threshold of(long size, SizeUnit unit)
Creates a new threshold.If the
sizeis less than 0, then theNONEinstance is returned regardless of theunit.- Parameters:
size- the maximum size of the thresholdunit- 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:
falseif the size is greater than the bytes allowed for this threshold, otherwisetrue
-
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
-
-