Interface IntElementRule<T>

Type Parameters:
T - generic type of time context compatible to ChronoEntity
All Superinterfaces:
ElementRule<T,​Integer>

public interface IntElementRule<T> extends ElementRule<T,​Integer>

Element rule with support for int-primitives.

Note: All implementations must be immutable.

Since:
3.15/4.12
Author:
Meno Hochschild
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    getInt​(T context)
    Yields the current value of associated element in given chronological context.
    boolean
    isValid​(T context, int value)
    Queries if given value is valid for the element associated with this rule in given context.
    withValue​(T context, int value, boolean lenient)
    Determines the new value of the associated element in given chronological context and yields the result.

    Methods inherited from interface net.time4j.engine.ElementRule

    getChildAtCeiling, getChildAtFloor, getMaximum, getMinimum, getValue, isValid, withValue
  • Method Details

    • getInt

      int getInt(T context)

      Yields the current value of associated element in given chronological context.

      Will be called by ChronoEntity.getInt(ChronoElement).

      Parameters:
      context - time context to be evaluated
      Returns:
      current element value as int-primitive
      Throws:
      ChronoException - if the associated element value cannot be evaluated
      Since:
      3.15/4.12
    • isValid

      boolean isValid(T context, int value)

      Queries if given value is valid for the element associated with this rule in given context.

      Will be called by ChronoEntity.isValid(ChronoElement, int). A numerical overflow causing an ArithmeticException will usually not be checked.

      Parameters:
      context - time context to be evaluated
      value - candidate value to be validated
      Returns:
      true if valid else false
      Since:
      3.15/4.12
    • withValue

      T withValue(T context, int value, boolean lenient)

      Determines the new value of the associated element in given chronological context and yields the result.

      Will be called by ChronoEntity.with(ChronoElement, int). The lenient mode causes the tolerant interpretation of invalid values like 31st of April as 1st of May. This mode is only active if an element is either explicitly declared as lenient or if the method StdOperator.setLenient() is used.

      Parameters:
      context - time context to be evaluated
      value - new element value
      lenient - leniency mode
      Returns:
      changed copy of context which itself remains unaffected
      Throws:
      IllegalArgumentException - if given value is out of range or not valid dependent on the given time context
      ArithmeticException - in case of numerical overflow
      Since:
      3.15/4.12
      See Also:
      isValid(Object, int), StdOperator.setLenient(Object, ChronoElement), ChronoElement.isLenient(), ProportionalElement.setLenient(Number)