Class EInterval.Builder

  • Enclosing class:
    EInterval

    public static final class EInterval.Builder
    extends EField.Builder<EInterval>
    EInterval instances may be created only by using a Builder instance. A Builder instance is obtained by calling EInterval.builder() which returns a newly instantiated Builder instance. It is recommended that a new Builder instance be used to create an interval rather than re-using a builder instance to create multiple intervals.
    • Method Detail

      • validate

        protected Validator validate​(Validator problems)
        Checks if:
        1. the begin and end times and clusivity are set and
        2. begin time is either < or ≤ end time depending on clusivity settings.
        3. if begin time equals end time then both times must be inclusive.
        Overrides:
        validate in class EField.Builder<EInterval>
        Parameters:
        problems - add each detected problem to this validator.
        Returns:
        problems.
        See Also:
        Validator
      • beginTime

        public EInterval.Builder beginTime​(java.time.Instant beginTime,
                                           EInterval.Clusivity clusivity)
        Sets interval begin time and clusivity. Begin time location is based on whether beginTime is < or ≥ to current time. Returns this Builder instance so that builder method calls can be chained.
        Parameters:
        beginTime - interval begin time.
        clusivity - interval begin time clusivity.
        Returns:
        this Builder instance.
        Throws:
        java.lang.NullPointerException - if either beginTime or clusivity is null. Note: if this is the case, then neither begin time nor clusivity is set.
        See Also:
        beginNow(Clusivity)
      • beginNow

        public EInterval.Builder beginNow​(EInterval.Clusivity clusivity)
        Sets interval begin time to current time and begin time location to EInterval.TimeLocation.NOW but the clusivity to the given value. When combined with clusivity defines whether interval begins at or just after now. Returns this Builder instance so that builder method calls can be chained.
        Parameters:
        clusivity - interval begin time clusivity.
        Returns:
        this Builder instance.
        Throws:
        java.lang.NullPointerException - if clusivity is null. If this is the case, then begin time and location are not set.
        See Also:
        beginTime(Instant, Clusivity)
      • endTime

        public EInterval.Builder endTime​(java.time.Instant endTime,
                                         EInterval.Clusivity clusivity)
        Sets interval end time and clusivity. End time location is based on whether endTime is < or ≥ to current time. Returns this Builder instance so that builder method calls can be chained.
        Parameters:
        endTime - interval end time.
        clusivity - interval end time clusivity.
        Returns:
        this Builder instance.
        Throws:
        java.lang.NullPointerException - if either endTime or clusivity is null. Note: if this is the case, then neither end time nor clusivity is set.
      • endNow

        public EInterval.Builder endNow​(EInterval.Clusivity clusivity)
        Sets interval end time to current time and end time location to EInterval.TimeLocation.NOW. When combined with clusivity defines whether interval end at or just before now. Returns this Builder instance so that builder method calls can be chained.
        Parameters:
        clusivity - interval end time clusivity.
        Returns:
        this Builder instance.
      • endNever

        public EInterval.Builder endNever()
        Sets interval end time to Instant.MAX and end time location to EInterval.TimeLocation.ON_GOING. Clusivity is set to exclusive but is irrelevant since the end time is never reached. Returns this Builder instance so that builder method calls can be chained.
        Returns:
        this Builder instance.
      • nowOnly

        public EInterval.Builder nowOnly()
        Sets interval for current time only, inclusive. Both begin and end times are set to now, clusivity set to inclusive, and time location to now. Returns this Builder instance so that builder method calls can be chained.
        Returns:
        this Builder instance.