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