Class Threshold

    • Method Detail

      • 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