Interface Duration

All Superinterfaces:
Comparable<Duration>, OsidPrimitive, Serializable
All Known Subinterfaces:
Duration

public interface Duration extends OsidPrimitive, Comparable<Duration>
Supplements the OSID Duration interface for Java.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compareTo(Duration duration)
    Compares this duration with the specified Duration to determine the natural order.
    boolean
    Determines if the given Duration is equal to this one.
    Gets the lower bound of the duration.
    Gets the upper bound of the duration.
    int
    Returns a hash code value for this Duration based on the types, values, granularity, and uncertainties.
    boolean
    Tests if the range of this Duration, as specified by its granularity and uncertainty, does not overlap the given Duration.
    boolean
    isGreater(Duration duration)
    Tests if this Duration is greater than the given Duration.
    boolean
    Tests if the range of this Duration, as specified by its granularity and uncertainty, includes the given Duration ranged by its grabularity and uncertainty.
    boolean
    isLess(Duration duration)
    Tests if this Duration is less than the given Duration.

    Methods inherited from interface OsidPrimitive

    toString
    Modifier and Type
    Method
    Description
    Returns a string representation of this OsidPrimitive.
  • Method Details

    • isGreater

      boolean isGreater(Duration duration)
      Tests if this Duration is greater than the given Duration. A greater Duration is one whose values minus uncertainty is greater than another plus its uncertainty and graularity. An uncertainty of infinity is undefined and returns false.
      Parameters:
      duration - the duration to compare
      Returns:
      true if this duration is larger, false otherwise
      Throws:
      NullArgumentException - duration is null
      UnsupportedException - cannot compare calendar
    • isLess

      boolean isLess(Duration duration)
      Tests if this Duration is less than the given Duration. A lesser Duration is one whose values plus granularity and uncertainty is less than another minus its d uncertainty. An uncertainty of infinity is undefined and returns false.
      Parameters:
      duration - the duration to compare
      Returns:
      true if this duration is less, false otherwise
      Throws:
      NullArgumentException - duration is null
      UnsupportedException - cannot compare calendar
    • isInclusive

      boolean isInclusive(Duration duration)
      Tests if the range of this Duration, as specified by its granularity and uncertainty, includes the given Duration ranged by its grabularity and uncertainty. If either duration has an uncertainty of infinity this method returns false.
      Parameters:
      duration - the duration to compare
      Returns:
      true if this duration includes the given duration, false otherwise
      Throws:
      NullArgumentException - duration is null
      UnsupportedException - cannot compare calendar
    • isExclusive

      boolean isExclusive(Duration duration)
      Tests if the range of this Duration, as specified by its granularity and uncertainty, does not overlap the given Duration. If either duration has an uncertainty of infinity this method returns false.
      Parameters:
      duration - the duration to compare
      Returns:
      true if this duration is excluded, false otherwise
      Throws:
      NullArgumentException - duration is null
      UnsupportedException - cannot compare calendar
    • getLowerBound

      Duration getLowerBound()
      Gets the lower bound of the duration. The lower bound is the duration minus the uncertainty.
      Returns:
      the duration lower bound
    • getUpperBound

      Duration getUpperBound()
      Gets the upper bound of the duration. The lower bound is the duration plus the uncertainty.
      Returns:
      the duration upper bound
    • compareTo

      int compareTo(Duration duration)
      Compares this duration with the specified Duration to determine the natural order. Returns a negative integer, zero, or a positive integer as this duration is less than, equal to, or greater than the specified Duration. The natural ordering is determined first by the natural ordering of the type, then by its values. This method is not useful for numeric comparisons. The ranges implied by their granularities and uncertainties may overlap in such a way that two unequal Durations may be neither less than or greater than the other. If compareTo a duration is zero, then equals() must be true and their hash codes must also be equal for consistent behavior. For orderings that may yield inconsistent behavior, an external Comparator should be used.
      Specified by:
      compareTo in interface Comparable<Duration>
      Parameters:
      duration - the duration to be compared
      Returns:
      a negative integer, zero, or a positive integer as this duration is less than, equal to, or greater than the specified duration
      Throws:
      ClassCastException - if the specified duration's type prevents it from being compared to this duration
    • equals

      boolean equals(Object obj)
      Determines if the given Duration is equal to this one. Two Durations are equal if their Types, granularities, values, and uncertainties are equal.
      Overrides:
      equals in class Object
      Parameters:
      obj - an object to compare
      Returns:
      true if the given object is equal to this Duration, false otherwise
    • hashCode

      int hashCode()
      Returns a hash code value for this Duration based on the types, values, granularity, and uncertainties.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object