Class PeriodAndDuration

java.lang.Object
com.microsoft.kiota.PeriodAndDuration
All Implemented Interfaces:
Serializable, Comparable<PeriodAndDuration>, TemporalAmount

public final class PeriodAndDuration extends Object implements TemporalAmount, Comparable<PeriodAndDuration>, Serializable
The aggregate type for Period and Duration
See Also:
  • Field Details

    • ZERO

      public static final PeriodAndDuration ZERO
      A constant for a duration of zero.
  • Method Details

    • getPeriod

      @Nonnull public Period getPeriod()
      Gets the period section of the type.
      Returns:
      the period section
    • getDuration

      @Nonnull public Duration getDuration()
      Gets the duration section of the type.
      Returns:
      the duration section
    • of

      @Nonnull public static PeriodAndDuration of(@Nonnull Period period, @Nonnull Duration duration)
      Creates an instance based on a period and duration.
      Parameters:
      period - the Period, not null
      duration - the Duration, not null
      Returns:
      the combined PeriodAndDuration, not null
    • ofPeriod

      @Nonnull public static PeriodAndDuration ofPeriod(@Nonnull Period period)
      Creates an instance based on a period.
      Parameters:
      period - the Period, not null
      Returns:
      the combined PeriodAndDuration, not null
    • ofDuration

      @Nonnull public static PeriodAndDuration ofDuration(@Nonnull Duration duration)
      Creates an instance based on a duration.
      Parameters:
      duration - the Duration, not null
      Returns:
      the combined PeriodAndDuration, not null
    • ofPeriodAndDuration

      @Nonnull public static PeriodAndDuration ofPeriodAndDuration(@Nonnull PeriodAndDuration periodAndDuration)
      Creates an instance based on a PeriodAndDuration.
      Parameters:
      periodAndDuration - the PeriodAndDuration, not null
      Returns:
      the combined PeriodAndDuration, not null
    • parse

      @Nonnull public static PeriodAndDuration parse(@Nonnull String stringValue)
      Parses a string to produce a PeriodAndDuration.
      Parameters:
      stringValue - the String parse from.
      Returns:
      parsed instance of PeriodAndDuration
    • compareTo

      public int compareTo(@Nonnull PeriodAndDuration periodAndDuration)
      Specified by:
      compareTo in interface Comparable<PeriodAndDuration>
      Parameters:
      periodAndDuration - the PeriodAndDuration for which to compare to
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
    • get

      public long get(@Nonnull TemporalUnit unit)
      Specified by:
      get in interface TemporalAmount
      Parameters:
      unit - the TemporalUnit for which to return the value
      Returns:
      the long value of the unit
    • getUnits

      public List<TemporalUnit> getUnits()
      Specified by:
      getUnits in interface TemporalAmount
      Returns:
      the List of TemporalUnits; not null
    • addTo

      public Temporal addTo(@Nonnull Temporal temporal)
      Specified by:
      addTo in interface TemporalAmount
      Parameters:
      temporal - the temporal object to add the amount to, not null
      Returns:
      an object of the same observable type with the addition made, not null
    • subtractFrom

      public Temporal subtractFrom(@Nonnull Temporal temporal)
      Specified by:
      subtractFrom in interface TemporalAmount
      Parameters:
      temporal - the temporal object to subtract the amount from, not null
      Returns:
      an object of the same observable type with the subtraction made, not null
    • toString

      public String toString()
      Returns a string representation of the instance in the ISO-8601 format 'PnYnMnDTnHnMnS'.
      Overrides:
      toString in class Object
      Returns:
      the period in ISO-8601 string format
    • hashCode

      public int hashCode()
      Gets the hashcode for the object.
      Overrides:
      hashCode in class Object
      Returns:
      The hashCode of the object
    • equals

      public boolean equals(Object otherPeriodAndDuration)
      Checks if this instance is equal to the specified PeriodAndDuration.
      Overrides:
      equals in class Object
      Parameters:
      otherPeriodAndDuration - the other Object, null returns false
      Returns:
      true if the other otherPeriodAndDuration is equal to this one