Package net.solarnetwork.domain.tariff
Class TemporalRangesTariff
java.lang.Object
net.solarnetwork.domain.tariff.TemporalRangesTariff
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.solarnetwork.domain.tariff.Tariff
Tariff.Rate -
Constructor Summary
ConstructorsConstructorDescriptionTemporalRangesTariff(String monthRange, String dayOfMonthRange, String dayOfWeekRange, String minuteOfDayRange, List<Tariff.Rate> rates, Locale locale) Constructor.TemporalRangesTariff(IntRange monthRange, IntRange dayOfMonthRange, IntRange dayOfWeekRange, IntRange minuteOfDayRange, List<Tariff.Rate> rates) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanapplies(TemporalRangesTariffEvaluator evaluator, LocalDateTime dateTime, Map<String, ?> parameters) Test if this rule applies according to a givenTemporalRangesTariffEvaluator.Get the day of month range.Get the day-of-week range.Get the minute-of-day range.Get the month-of-year range.getRates()Get the rates that apply with this tariff.rangeForField(ChronoField field) Get a range for a given temporal field.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.solarnetwork.domain.tariff.Tariff
toTemporalTariff
-
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 tarifflocale- the locale
-
-
Method Details
-
getRates
Description copied from interface:TariffGet the rates that apply with this tariff. -
rangeForField
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 givenTemporalRangesTariffEvaluator.- Parameters:
evaluator- the evaluator to usedateTime- the date timeparameters- the parameters- Returns:
- the result of calling
TemporalRangesTariffEvaluator.applies(TemporalRangesTariff, LocalDateTime, Map)with this object
-
toString
-
getMonthRange
Get the month-of-year range.- Returns:
- the month range, from 1 - 12
-
getDayOfMonthRange
Get the day of month range.- Returns:
- the day range, from 1 - 31
-
getDayOfWeekRange
Get the day-of-week range.- Returns:
- the weekday range, from 1-7 with Monday being 1
-
getMinuteOfDayRange
Get the minute-of-day range.- Returns:
- the range, from 0 - 1440
-