Package org.assertj.core.data
Class TemporalUnitOffset
- java.lang.Object
-
- org.assertj.core.data.TemporalUnitOffset
-
- All Implemented Interfaces:
TemporalOffset<Temporal>
- Direct Known Subclasses:
TemporalUnitLessThanOffset
,TemporalUnitWithinOffset
public abstract class TemporalUnitOffset extends Object implements TemporalOffset<Temporal>
Base class forTemporalOffset
on basis ofTemporalUnit
.- Since:
- 3.7.0
-
-
Field Summary
Fields Modifier and Type Field Description protected TemporalUnit
unit
protected long
value
-
Constructor Summary
Constructors Constructor Description TemporalUnitOffset(long value, TemporalUnit unit)
Creates a new temporal offset for a given temporal unit.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
checkThatValueIsPositive(long value)
boolean
equals(Object obj)
protected Duration
getAbsoluteDuration(Temporal temporal1, Temporal temporal2)
Returns absolute value of the difference as Duration.String
getBeyondOffsetDifferenceDescription(Temporal temporal1, Temporal temporal2)
Returns description of the difference between temporal values and expected offset details.protected long
getDifference(Temporal temporal1, Temporal temporal2)
Returns absolute value of the difference according to time unit.TemporalUnit
getUnit()
int
hashCode()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.data.TemporalOffset
isBeyondOffset
-
-
-
-
Field Detail
-
unit
protected final TemporalUnit unit
-
value
protected final long value
-
-
Constructor Detail
-
TemporalUnitOffset
public TemporalUnitOffset(long value, TemporalUnit unit)
Creates a new temporal offset for a given temporal unit.- Parameters:
value
- the value of the offset.unit
- temporal unit of the offset.- Throws:
NullPointerException
- if the given unit isnull
.IllegalArgumentException
- if the given value is negative.
-
-
Method Detail
-
checkThatValueIsPositive
private static void checkThatValueIsPositive(long value)
-
getBeyondOffsetDifferenceDescription
public String getBeyondOffsetDifferenceDescription(Temporal temporal1, Temporal temporal2)
Returns description of the difference between temporal values and expected offset details. Is designed for the case when difference is beyond offset.- Specified by:
getBeyondOffsetDifferenceDescription
in interfaceTemporalOffset<Temporal>
- Parameters:
temporal1
- first temporal value which is being validated against second temporal value.temporal2
- second temporal value.- Returns:
- difference description.
-
getDifference
protected long getDifference(Temporal temporal1, Temporal temporal2)
Returns absolute value of the difference according to time unit.
-
getAbsoluteDuration
protected Duration getAbsoluteDuration(Temporal temporal1, Temporal temporal2)
Returns absolute value of the difference as Duration.
-
getUnit
public TemporalUnit getUnit()
-
-