Class TemporalUnitOffset

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.time.temporal.TemporalUnit unit  
      protected long value  
    • 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 Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static void checkThatValueIsPositive​(long value)  
      boolean equals​(java.lang.Object obj)  
      protected java.time.Duration getAbsoluteDuration​(java.time.temporal.Temporal temporal1, java.time.temporal.Temporal temporal2)
      Returns absolute value of the difference as Duration.
      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()  
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • unit

        protected final java.time.temporal.TemporalUnit unit
      • value

        protected final long value
    • 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 is null.
        java.lang.IllegalArgumentException - if the given value is negative.
    • Method Detail

      • checkThatValueIsPositive

        private static 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 interface TemporalOffset<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 first Temporal
        temporal2 - the second Temporal
        Returns:
        absolute value of the difference according to time unit.
      • getAbsoluteDuration

        protected java.time.Duration getAbsoluteDuration​(java.time.temporal.Temporal temporal1,
                                                         java.time.temporal.Temporal temporal2)
        Returns absolute value of the difference as Duration.
        Parameters:
        temporal1 - the first Temporal
        temporal2 - the second Temporal
        Returns:
        absolute value of the difference as Duration.
      • getUnit

        public java.time.temporal.TemporalUnit getUnit()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object