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