Package org.assertj.core.data
Class TemporalUnitOffset
- java.lang.Object
-
- org.assertj.core.data.TemporalUnitOffset
-
- All Implemented Interfaces:
TemporalOffset<java.time.temporal.Temporal>
- Direct Known Subclasses:
TemporalUnitLessThanOffset
,TemporalUnitWithinOffset
public abstract class TemporalUnitOffset extends java.lang.Object implements TemporalOffset<java.time.temporal.Temporal>
Base class forTemporalOffset
on basis ofTemporalUnit
.- Since:
- 3.7.0
-
-
Constructor Summary
Constructors Constructor Description TemporalUnitOffset(long value, java.time.temporal.TemporalUnit unit)
Creates a new temporal offset for a given temporal unit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkThatValueIsPositive(long value)
java.lang.String
getBeyondOffsetDifferenceDescription(java.time.temporal.Temporal temporal1, java.time.temporal.Temporal temporal2)
Returns description of the difference between temporal values and expected offset details.protected long
getDifference(java.time.temporal.Temporal temporal1, java.time.temporal.Temporal temporal2)
Returns absolute value of the difference according to time unit.java.time.temporal.TemporalUnit
getUnit()
long
getValue()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.data.TemporalOffset
isBeyondOffset
-
-
-
-
Constructor Detail
-
TemporalUnitOffset
public TemporalUnitOffset(long value, java.time.temporal.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:
java.lang.NullPointerException
- if the given unit isnull
.java.lang.IllegalArgumentException
- if the given value is negative.
-
-
Method Detail
-
checkThatValueIsPositive
private void checkThatValueIsPositive(long value)
-
getBeyondOffsetDifferenceDescription
public java.lang.String getBeyondOffsetDifferenceDescription(java.time.temporal.Temporal temporal1, java.time.temporal.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<java.time.temporal.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(java.time.temporal.Temporal temporal1, java.time.temporal.Temporal temporal2)
Returns absolute value of the difference according to time unit.- Parameters:
temporal1
- the firstTemporal
temporal2
- the secondTemporal
- Returns:
- absolute value of the difference according to time unit.
-
getUnit
public java.time.temporal.TemporalUnit getUnit()
-
getValue
public long getValue()
-
-