java.lang.Object
de.powerstat.validation.values.Months
- All Implemented Interfaces:
IValueObject
,Comparable<Months>
Months.
Not DSGVO relevant.
TODO min, max
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd other months to this months.int
Compare with another object.divide
(long divisor) Divide months by a divisor.boolean
Is equal with another object.int
hashCode()
Calculate hash code.long
Returns the value of this Months as a long.modulo
(long divisor) Floor modulo months by a divisor.multiply
(long multiplier) Multiply months with a multiplier.static Months
of
(long months) Months factory.static Months
Months factory.Returns the value of this Months as a String.Subtract other months from this months.toString()
Returns the string representation of this Months.
-
Field Details
-
months
private final long monthsMonth.
-
-
Constructor Details
-
Months
private Months(long months) Constructor.- Parameters:
months
- Months 0-..- Throws:
IndexOutOfBoundsException
- When the months is less than 0
-
-
Method Details
-
of
Months factory.- Parameters:
months
- Months 0-..- Returns:
- Months object
-
of
Months factory.- Parameters:
value
- Months 0-.. string- Returns:
- Months object
-
longValue
public long longValue()Returns the value of this Months as a long.- Returns:
- The numeric value represented by this object after conversion to type long.
-
stringValue
Returns the value of this Months as a String.- Specified by:
stringValue
in interfaceIValueObject
- Returns:
- The numeric value represented by this object after conversion to type String.
-
hashCode
public int hashCode()Calculate hash code. -
equals
Is equal with another object. -
toString
Returns the string representation of this Months. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "Months[months=1]" -
compareTo
Compare with another object.- Specified by:
compareTo
in interfaceComparable<Months>
- Parameters:
obj
- Object to compare with- Returns:
- 0: equal; 1: greater; -1: smaller
- See Also:
-
add
Add other months to this months.- Parameters:
other
- Other months to add to this months- Returns:
- New months after adding other months to this months
- Throws:
ArithmeticException
- In case of an overflow
-
subtract
Subtract other months from this months.- Parameters:
other
- Other months to subtract from this one- Returns:
- Absolute new months after subtracting other months from this months
-
multiply
Multiply months with a multiplier.- Parameters:
multiplier
- Multiplier to multiply with- Returns:
- New months that is a multiplication of this months with the multiplier
- Throws:
ArithmeticException
- In case of an overflow
-
divide
Divide months by a divisor.- Parameters:
divisor
- Divisor to divide by- Returns:
- The largest (closest to positive infinity) long value that is less than or equal to the algebraic quotient.
- Throws:
ArithmeticException
- In case the divisor is 0.
-
modulo
Floor modulo months by a divisor.- Parameters:
divisor
- Divisor to divide by- Returns:
- The floor modulus Months - (floorDiv(Months, divisor) * divisor)
- Throws:
ArithmeticException
- In case the divisor is 0.
-