Interface IYearMonthDurationItem

All Superinterfaces:
IAnyAtomicItem, IAtomicValuedItem, ICollectionValue, IDurationItem, IItem

public interface IYearMonthDurationItem extends IDurationItem
An atomic Metapath item containing a duration data value in years, months, and days.
  • Method Details

    • type

      @NonNull static IAtomicOrUnionType<IYearMonthDurationItem> type()
      Get the type information for this item.
      Returns:
      the type information
    • getType

      Description copied from interface: IItem
      Get the type information for the item.
      Specified by:
      getType in interface IItem
      Returns:
      the item's type information
    • valueOf

      @NonNull static IYearMonthDurationItem valueOf(@NonNull String value)
      Construct a new year month day duration item using the provided string value.
      Parameters:
      value - a string representing a year month day duration
      Returns:
      the new item
      Throws:
      InvalidTypeMetapathException - if the provided string value is not a day/time duration value according to ISO 8601
    • valueOf

      @NonNull static IYearMonthDurationItem valueOf(@NonNull Period value)
      Construct a new year month day duration item using the provided value.
      Parameters:
      value - a duration
      Returns:
      the new item
    • valueOf

      @NonNull static IYearMonthDurationItem valueOf(int years, int months)
      Construct a new year month day duration item using the provided values.
      Parameters:
      years - the number of years in the period
      months - the number of months in the period
      Returns:
      the new item
    • asPeriod

      @NonNull Period asPeriod()
      Get the "wrapped" duration value.
      Returns:
      the underlying duration value
    • asTotalMonths

      default long asTotalMonths()
      Get the total quantity of months this duration represents.
      Returns:
      the total months
    • negate

      @NonNull default IYearMonthDurationItem negate()
      Returns a new instance with each amount in this period negated.
      Returns:
      the new negated instance
    • cast

      @NonNull static IYearMonthDurationItem cast(@NonNull IAnyAtomicItem item)
      Cast the provided type to this item type.
      Parameters:
      item - the item to cast
      Returns:
      the original item if it is already this type, otherwise a new item cast to this type
      Throws:
      InvalidValueForCastFunctionException - if the provided item cannot be cast to this type
    • castAsType

      default IYearMonthDurationItem castAsType(IAnyAtomicItem item)
      Description copied from interface: IAnyAtomicItem
      Cast the provided item to be the same type as this item.
      Specified by:
      castAsType in interface IAnyAtomicItem
      Specified by:
      castAsType in interface IDurationItem
      Parameters:
      item - the item to cast
      Returns:
      an atomic item of this type
    • compareTo

      default int compareTo(IYearMonthDurationItem item)
      Compares this value with the argument.
      Parameters:
      item - the item to compare with this value
      Returns:
      a negative integer, zero, or a positive integer if this value is less than, equal to, or greater than the item.