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 boolean
equals(Object obj)
int
hashCode()
static Threshold
of(long size, SizeUnit unit)
Creates a new threshold.boolean
reached(long size)
Checks if the given size is greater than the bytes available for the threshold.SizeUnit
sizeUnit()
Returns the size unit for this threshold.long
toBytes()
The size in bytes for this threshold.String
toString()
static Threshold
valueOf(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
size
is less than 0, then theNONE
instance 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:
false
if 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
-
-