java.lang.Object
oracle.communication.brm.charging.util.directevolution.DAbstractEvolvable
oracle.communication.brm.charging.util.range.Range
All Implemented Interfaces:
Serializable, Cloneable, oracle.communication.brm.charging.util.directevolution.DEvolvable, Ranges<Long>

public final class Range extends oracle.communication.brm.charging.util.directevolution.DAbstractEvolvable implements Ranges<Long>
An Range is an interval with start and end boundary The start is inclusive but the end is not. Boundaries must be of type long Typically, they expressed time in milliseconds since 1970-01-01T00:00:00Z.

A range must abide by the following contract:

  • It must be immutable
  • 2 ranges are equals if and only if they have the same start and end
  • Follow the contract defined by the methods javadoc
  • See Also:
    • Field Details

    • Constructor Details

      • Range

        public Range()
        Default constructor required for evolution
    • Method Details

      • make

        public static Range make(long start, long end)
        factory method
        Parameters:
        start - start time
        end - end time
        Returns:
        new Range
      • createInstance

        public oracle.communication.brm.charging.util.directevolution.DEvolvable createInstance()
        Specified by:
        createInstance in interface oracle.communication.brm.charging.util.directevolution.DEvolvable
      • giveInitializerTo

        public void giveInitializerTo(oracle.communication.brm.charging.util.directevolution.DEvolvableHelper evolvableHelper)
        Specified by:
        giveInitializerTo in interface oracle.communication.brm.charging.util.directevolution.DEvolvable
      • empty

        public Ranges<Long> empty()
        Description copied from interface: Ranges
        A range of size 0L starting at this instance start time
        Specified by:
        empty in interface Ranges<Long>
        Returns:
        empty range
      • plus

        public Ranges<Long> plus(Ranges<Long> right)
        Description copied from interface: Ranges
        Add 2 ranges
        Specified by:
        plus in interface Ranges<Long>
        Parameters:
        right - right operand
        Returns:
        sum of ranges
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Ranges<Long>
        Returns:
        whether this object is an empty range
      • intersect

        public Ranges<Long> intersect(Ranges<Long> right)
        Description copied from interface: Ranges
        Get the common range between 2 ranges. No restrictions.
        Specified by:
        intersect in interface Ranges<Long>
        Parameters:
        right - right operand
        Returns:
        the common range or the empty range if the ranges do not intersect.
      • size

        public Long size()
        Specified by:
        size in interface Ranges<Long>
        Returns:
        range size
      • shift

        public Range shift(Long offset)
        Specified by:
        shift in interface Ranges<Long>
        Parameters:
        offset - offset to shift
        Returns:
        shift start and end by the same positive or negative value
      • end

        public Long end()
        Specified by:
        end in interface Ranges<Long>
        Returns:
        end
      • start

        public Long start()
        Specified by:
        start in interface Ranges<Long>
        Returns:
        start
      • minus

        public Ranges<Long> minus(Ranges<Long> right)
        Description copied from interface: Ranges
        filter range: exclude a range from current range Note: does not support excluding a range that would result in more than one range.
        Specified by:
        minus in interface Ranges<Long>
        Parameters:
        right - excluded range
        Returns:
        part of this range that does not include right
      • getRanges

        public List<Range> getRanges()
        Specified by:
        getRanges in interface Ranges<Long>
        Returns:
        a collection of range objects [ only subclasses of Ranges ]
      • contains

        public boolean contains(Long value)
        Description copied from interface: Ranges
        Whether an instant is within the range boundaries (lower bound is inclusive, upper bound is exclusive)
        Specified by:
        contains in interface Ranges<Long>
        Parameters:
        value - instant
        Returns:
        true if instant time is within range, false otherwise
      • toString

        public String toString()
        Overrides:
        toString in class oracle.communication.brm.charging.util.directevolution.DAbstractEvolvable
      • toTimeOfDayString

        public String toTimeOfDayString()
      • equals

        public boolean equals(Object o)
        Specified by:
        equals in interface Ranges<Long>
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface Ranges<Long>
        Overrides:
        hashCode in class Object
      • toRangesString

        public String toRangesString()
        Specified by:
        toRangesString in interface Ranges<Long>
        Returns:
        string representation of the ranges