Class Rule

  • All Implemented Interfaces:
    Copy<ch.poole.openinghoursparser.Element>

    public class Rule
    extends java.lang.Object
    Container for objects from the opening_hours specification
    • Constructor Detail

      • Rule

        public Rule()
        Default constructor
      • Rule

        public Rule​(@NotNull
                    @NotNull Rule r)
        Copy constructor
        Parameters:
        r - the rule to copy
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toDebugString

        public java.lang.String toDebugString()
        Create a string that identifies which class created it for debugging and testing
        Returns:
        the output of toString with the class name prepended
      • equals

        public boolean equals​(java.lang.Object other)
      • hashCode

        public int hashCode()
      • isMergeableWith

        public boolean isMergeableWith​(Rule r)
        Returns true if the input only differs in the days and times objects Current considers comments significant
        Parameters:
        r - rule to test against
        Returns:
        true if r can be merged with this rule
      • isFallBack

        public boolean isFallBack()
        Returns:
        the fallBack
      • isAdditive

        public boolean isAdditive()
        Returns:
        true if this rule does not overwrite rules for days with previous rules
      • getComment

        public java.lang.String getComment()
        Returns:
        the comment
      • isTwentyfourseven

        public boolean isTwentyfourseven()
        Returns:
        the twentyfourseven
      • setTwentyfourseven

        public void setTwentyfourseven​(boolean twentyfourseven)
        Parameters:
        twentyfourseven - the twentyfourseven to set
      • getYears

        @Nullable
        public @Nullable java.util.List<YearRange> getYears()
        Get a List of YearRange objects
        Returns:
        a List of YearRange objects or null if none exist
      • getWeeks

        @Nullable
        public @Nullable java.util.List<WeekRange> getWeeks()
        Get a List of WeekRange objects
        Returns:
        a List of WeekRange objects or null if none exist
      • getDates

        @Nullable
        public @Nullable java.util.List<DateRange> getDates()
        Get a List of DateRange objects
        Returns:
        a List of DateRange objects or null if none exist
      • getHolidays

        @Nullable
        public @Nullable java.util.List<Holiday> getHolidays()
        Get a List of Holiday objects
        Returns:
        a List of Holiday objects or null if none exists
      • getDays

        @Nullable
        public @Nullable java.util.List<WeekDayRange> getDays()
        Get a List of WeekDayRange objects
        Returns:
        a List of WeekDayRange objects or null if none exists
      • getTimes

        @Nullable
        public @Nullable java.util.List<TimeSpan> getTimes()
        Get a List of TimeSpan objects
        Returns:
        a List of TimeSpan objects or null if none exists
      • getModifier

        @Nullable
        public @Nullable RuleModifier getModifier()
        Get the RuleModifier
        Returns:
        the modifier or null if none set
      • setFallBack

        public void setFallBack​(boolean fallBack)
        Set the fallback flag for this rule
        Parameters:
        fallBack - if true this is a fallback rule
      • setAdditive

        public void setAdditive​(boolean additive)
        Set the additive flag for this rule
        Parameters:
        additive - if true this is an additive rule
      • setComment

        public void setComment​(@Nullable
                               @Nullable java.lang.String comment)
        Set the comment for this rule
        Parameters:
        comment - the comment to set
      • setYears

        public void setYears​(@Nullable
                             @Nullable java.util.List<YearRange> years)
        Set the List of YearRange objects
        Parameters:
        years - the List of YearRange objects or null
      • setWeeks

        public void setWeeks​(@Nullable
                             @Nullable java.util.List<WeekRange> weeks)
        Set the List of WeekRange objects
        Parameters:
        weeks - the List of WeekRange objects or null
      • setMonthdays

        @Deprecated
        public void setMonthdays​(@Nullable
                                 @Nullable java.util.List<DateRange> monthdays)
        Deprecated.
        Use setDates instead
        Set the list of DateRange objects
        Parameters:
        monthdays - a List of DateRange objects or null
      • setDates

        public void setDates​(@Nullable
                             @Nullable java.util.List<DateRange> dates)
        Set the list of DateRange objects
        Parameters:
        dates - a List of DateRange objects or null
      • setHolidays

        public void setHolidays​(@Nullable
                                @Nullable java.util.List<Holiday> holidays)
        Set the List of Holiday objects
        Parameters:
        holidays - the List of Holiday objects or null
      • setDays

        public void setDays​(@Nullable
                            @Nullable java.util.List<WeekDayRange> days)
        Set the list of WeekDayRange objects
        Parameters:
        days - a List of WeekDayRange objects or null
      • setTimes

        public void setTimes​(@Nullable
                             @Nullable java.util.List<TimeSpan> times)
        Set the list of TimeSpan objects
        Parameters:
        times - a List of TimeSpan objects or null
      • setModifier

        public void setModifier​(RuleModifier modifier)
        Parameters:
        modifier - the modifier to set
      • isEmpty

        public boolean isEmpty()
        Check if this rule actually contains something
        Returns:
        true if empty
      • copy

        public Rule copy()
        Description copied from interface: Copy
        Create a copy of the objecz
        Returns:
        a copy of the object