Class YearMatcher

java.lang.Object
org.kigalisim.engine.state.YearMatcher

public class YearMatcher extends Object
Class representing a range of years where inclusion can be tested.

This class provides functionality to test whether a given year falls within a specified range, supporting both bounded and unbounded ranges.

License:
BSD-3-Clause
  • Constructor Details

    • YearMatcher

      public YearMatcher(Optional<Integer> start, Optional<Integer> end)
      Create a new year range.

      Create a new year range between start and end where empty Optional in either means positive or negative infinity.

      Parameters:
      start - The starting year (inclusive) in this range or empty if no min year
      end - The ending year (inclusive) in this range or empty if no max year
    • YearMatcher

      public YearMatcher(Integer start, Integer end)
      Create a new year range from Integer values.

      Create a new year range between start and end where null in either means positive or negative infinity.

      Parameters:
      start - The starting year (inclusive) in this range or null if no min year
      end - The ending year (inclusive) in this range or null if no max year
  • Method Details

    • unbounded

      public static YearMatcher unbounded()
      Create a new unbounded year range.

      Create a new year range with no bounds (matches any year).

      Returns:
      A YearMatcher with no bounds
    • getInRange

      public boolean getInRange(int year)
      Determine if a year is included in this range.
      Parameters:
      year - The year to test for inclusion
      Returns:
      true if this value is between getStart and getEnd
    • getStart

      public Optional<Integer> getStart()
      Get the start of the year range.
      Returns:
      The minimum included year in this range or empty if negative infinity
    • getEnd

      public Optional<Integer> getEnd()
      Get the end of the year range.
      Returns:
      The maximum included year in this range or empty if positive infinity