Record Class ContractScheduleData
- Record Components:
startDate- the day the contract begins, ornullwhen not yet settledendDate- the day the contract ends, ornullwhen open-endedlengthInMonths- the contract's length in months
Either endpoint may be absent: a contract can be held without a settled schedule, and a save need not carry both
dates. isActiveOn(LocalDate) treats a missing endpoint as unbounded on that side, matching the convention
used when sorting missions - an active contract with no start date is treated as starting today.
-
Constructor Summary
ConstructorsConstructorDescriptionContractScheduleData(LocalDate startDate, LocalDate endDate, int lengthInMonths) Creates an instance of aContractScheduleDatarecord class. -
Method Summary
Modifier and TypeMethodDescriptionendDate()Returns the value of theendDaterecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisActiveOn(LocalDate date) intReturns the value of thelengthInMonthsrecord component.Returns the value of thestartDaterecord component.final StringtoString()Returns a string representation of this record class.withEndDate(LocalDate endDate) Returns a copy withendDatereplaced.withStartDate(LocalDate startDate) Returns a copy withstartDatereplaced.
-
Constructor Details
-
ContractScheduleData
public ContractScheduleData(@Nullable LocalDate startDate, @Nullable LocalDate endDate, int lengthInMonths) Creates an instance of aContractScheduleDatarecord class.- Parameters:
startDate- the value for thestartDaterecord componentendDate- the value for theendDaterecord componentlengthInMonths- the value for thelengthInMonthsrecord component
-
-
Method Details
-
withStartDate
Returns a copy withstartDatereplaced.lengthInMonthsis recomputed from the resulting dates, so it always describes the span the contract actually runs for rather than a separately agreed figure. Moving only the start date therefore shortens or lengthens the contract; a caller that means to shift the whole contract unchanged must move both endpoints (as chainingwithStartDate(...).withEndDate(...)does, where the final recomputed length comes back identical). The length is left untouched when either resulting date is absent, since there is no span to measure.- Parameters:
startDate- the replacement start date- Returns:
- a copy of this schedule with
startDatereplaced and the length recomputed
-
withEndDate
Returns a copy withendDatereplaced. As withwithStartDate(LocalDate), the length is recomputed from the resulting dates - pushing the end date back is what lengthens (or an extension shortens) the contract.- Parameters:
endDate- the replacement end date- Returns:
- a copy of this schedule with
endDatereplaced and the length recomputed
-
isActiveOn
- Parameters:
date- the day to test- Returns:
- whether the contract runs on
date, inclusive of both endpoints. An absent start date counts as already begun and an absent end date as not yet over, so a contract with neither is active on any day.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
startDate
Returns the value of thestartDaterecord component.- Returns:
- the value of the
startDaterecord component
-
endDate
Returns the value of theendDaterecord component.- Returns:
- the value of the
endDaterecord component
-
lengthInMonths
public int lengthInMonths()Returns the value of thelengthInMonthsrecord component.- Returns:
- the value of the
lengthInMonthsrecord component
-