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