Class TemporalRangesTariff

java.lang.Object
net.solarnetwork.domain.tariff.TemporalRangesTariff
All Implemented Interfaces:
Tariff

public class TemporalRangesTariff extends Object implements Tariff
A tariff with time-based range rules.

The rules associated with this tariff are represented by a set of date ranges that serve as the constraints that must be satisfied by a given date for the rule to apply.

  • Constructor Details

    • TemporalRangesTariff

      public TemporalRangesTariff(IntRange monthRange, IntRange dayOfMonthRange, IntRange dayOfWeekRange, IntRange minuteOfDayRange, List<Tariff.Rate> rates)
      Constructor.
      Parameters:
      monthRange - the month range (months are 1-12)
      dayOfMonthRange - the day of month range (1-31)
      dayOfWeekRange - the day of week range (1-7, with 1 = Monday, 7 = Sunday)
      minuteOfDayRange - the minute of day range (0-1440)
      rates - a list of rates associated with the tariff
    • TemporalRangesTariff

      public TemporalRangesTariff(String monthRange, String dayOfMonthRange, String dayOfWeekRange, String minuteOfDayRange, List<Tariff.Rate> rates, Locale locale)
      Constructor.
      Parameters:
      monthRange - the month range (months are 1-12)
      dayOfMonthRange - the day of month range (1-31)
      dayOfWeekRange - the day of week range (1-7, with 1 = Monday, 7 = Sunday)
      minuteOfDayRange - the minute of day range (0-1440)
      rates - a list of rates associated with the tariff
      locale - the locale
  • Method Details

    • getRates

      public Map<String,Tariff.Rate> getRates()
      Description copied from interface: Tariff
      Get the rates that apply with this tariff.
      Specified by:
      getRates in interface Tariff
      Returns:
      the rates, as a mapping of rate IDs to associated rates, never null
    • rangeForField

      public IntRange rangeForField(ChronoField field)
      Get a range for a given temporal field.
      Parameters:
      field - the field to get the range for
      Returns:
      the associated range, or null if the field is not supported or the range is null
    • applies

      public boolean applies(TemporalRangesTariffEvaluator evaluator, LocalDateTime dateTime, Map<String,?> parameters)
      Test if this rule applies according to a given TemporalRangesTariffEvaluator.
      Parameters:
      evaluator - the evaluator to use
      dateTime - the date time
      parameters - the parameters
      Returns:
      the result of calling TemporalRangesTariffEvaluator.applies(TemporalRangesTariff, LocalDateTime, Map) with this object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getMonthRange

      public IntRange getMonthRange()
      Get the month-of-year range.
      Returns:
      the month range, from 1 - 12
    • getDayOfMonthRange

      public IntRange getDayOfMonthRange()
      Get the day of month range.
      Returns:
      the day range, from 1 - 31
    • getDayOfWeekRange

      public IntRange getDayOfWeekRange()
      Get the day-of-week range.
      Returns:
      the weekday range, from 1-7 with Monday being 1
    • getMinuteOfDayRange

      public IntRange getMinuteOfDayRange()
      Get the minute-of-day range.
      Returns:
      the range, from 0 - 1440