Verifies that the given period is valid

@param period
330733
public static void validatePeriod(Duration period) {
		if(period.equals(Duration.ZERO)) {
			String message = "The period must be nonzero";
			throw new IllegalArgumentException(message);
		}
	}
1008779
static int parsePeriod(
        String period,
        char symbol
    ) throws ParseException {

        if (period.isEmpty()) {
            throw new ParseException("Empty period.", 0);
        }

        boolean negative = false;
        int index = 0;
        int len = period.length();

        if (period.charAt(0) == '-') {
            index++;
            negative = true;
        }

        if ((index < len) && (period.charAt(index) != 'P')) {
            throw new ParseException("Missing P-literal: " + period, index);
        }

        index++;
        long total = 0;
        int old = index;

        for (int i = index, n = Math.min(len, 10); i < n; i++) {
            char c = period.charAt(i);
            if ((c >= '0') && (c <= '9')) {
                int digit = (c - '0');
                total = total * 10 + digit;
                index++;
            } else {
                break;
            }
        }

        if (index == old) {
            throw new ParseException("Missing digits: " + period, index);
        }

        if ((len == index + 1) && (period.charAt(index) == symbol)) {
            index++; // consume unit symbol
            try {
                if (negative) {
                    total = MathUtils.safeNegate(total);
                }
                return MathUtils.safeCast(total);
            } catch (ArithmeticException ae) {
                throw new ParseException(ae.getMessage(), index);
            }
        }

        throw new ParseException("Unparseable format: " + period, index);

    }
742540
protected final boolean isDurationValid() {

        if (isValidEndTypeForPattern()) {
            switch (getEndType()) {
                case DATE:
                    return (getStart().getTime() < (getSeriesEndDate().getTime() + DAY_IN_MILLIS));
                case TIMES:
                    return getOccurrences() > 0;
                case SINGLE:
                    return true;
                default:
                    return false;
            }
        } else {
            return false;
        }
    }
1315181
public static void checkMinimalPollingPeriod(TimeUnit pollUnit, int pollPeriod)
      throws IllegalArgumentException {
    int period = (int) MINIMAL_POLL_UNIT.convert(pollPeriod, pollUnit);
    Preconditions.checkArgument(period >= MINIMAL_POLL_PERIOD,
        "Polling period %d %d is below the minimal polling period", pollPeriod, pollUnit);
  }
356710
def initialize_period(self, period=None):
        
        if not period:
            self.current_period = dt.datetime.now()
        else:
            self.current_period = period
        self.current_period = dt.datetime(self.current_period.year, self.current_period.month, self.current_period.day)
        self.date = self.current_period.strftime("%Y-%m-%d")
978793
def is_correct(self):
        
        valid = True
        # We do not want a same hg to be explode again and again
        # so we tag it
        for timeperiod in list(self.items.values()):
            timeperiod.rec_tag = False

        for timeperiod in list(self.items.values()):
            for tmp_tp in list(self.items.values()):
                tmp_tp.rec_tag = False
            valid = timeperiod.check_exclude_rec() and valid

        # We clean the tags and collect the warning/erro messages
        for timeperiod in list(self.items.values()):
            del timeperiod.rec_tag

            # Now other checks
            if not timeperiod.is_correct():
                valid = False
                source = getattr(timeperiod, 'imported_from', "unknown source")
                msg = "Configuration in %s::%s is incorrect; from: %s" % (
                    timeperiod.my_type, timeperiod.get_name(), source
                )
                self.add_error(msg)

            self.configuration_errors += timeperiod.configuration_errors
            self.configuration_warnings += timeperiod.configuration_warnings

        # And check all timeperiods for correct (sunday is false)
        for timeperiod in self:
            valid = timeperiod.is_correct() and valid

        return valid
338514
@Override
    public boolean isValid(TagData us) {
        if (!Util.isSpecified(us, ITEMS)) {
            if (!Util.isSpecified(us, BEGIN) || !(Util.isSpecified(us, END))) {
                return false;
            }
        }
        return true;
    }
212790
public final void mPERIOD() throws RecognitionException {
		try {
			int _type = PERIOD;
			int _channel = DEFAULT_TOKEN_CHANNEL;
			// druidG.g:617:8: ( ( 'PERIOD' ) )
			// druidG.g:617:10: ( 'PERIOD' )
			{
			// druidG.g:617:10: ( 'PERIOD' )
			// druidG.g:617:11: 'PERIOD'
			{
			match("PERIOD"); 

			}

			}

			state.type = _type;
			state.channel = _channel;
		}
		finally {
			// do for sure before leaving
		}
	}
569320
public static boolean isValidIp(final String ip) {
		if (ip == null || ip.length() == 0) {
			return false;
		}
		Matcher m = IS_VALID_IP_PATTERN.matcher(ip);
		return m.find();
		// return false;
		// }
		// return true;
	}
441686
def _check_period_consistency(self, period, variable):
        
        if variable.definition_period == periods.ETERNITY:
            return  # For variables which values are constant in time, all periods are accepted

        if variable.definition_period == periods.MONTH and period.unit != periods.MONTH:
            raise ValueError("Unable to compute variable '{0}' for period {1}: '{0}' must be computed for a whole month. You can use the ADD option to sum '{0}' over the requested period, or change the requested period to 'period.first_month'.".format(
                variable.name,
                period
                ))

        if variable.definition_period == periods.YEAR and period.unit != periods.YEAR:
            raise ValueError("Unable to compute variable '{0}' for period {1}: '{0}' must be computed for a whole year. You can use the DIVIDE option to get an estimate of {0} by dividing the yearly value by 12, or change the requested period to 'period.this_year'.".format(
                variable.name,
                period
                ))

        if period.size != 1:
            raise ValueError("Unable to compute variable '{0}' for period {1}: '{0}' must be computed for a whole {2}. You can use the ADD option to sum '{0}' over the requested period.".format(
                variable.name,
                period,
                'month' if variable.definition_period == periods.MONTH else 'year'
                ))
790689
@Override
    public <V> boolean isValid(
        ChronoElement<V> element,
        V value // optional
    ) {

        if (element == null) {
            throw new NullPointerException("Missing chronological element.");
        }

        return true;

    }
345827
private static boolean _isValidForCycle (@Nonnull final Holiday aHoliday, final int nYear)
  {
    final String sEvery = aHoliday.getEvery ();
    if (sEvery != null && !"EVERY_YEAR".equals (sEvery))
    {
      if ("ODD_YEARS".equals (sEvery))
        return nYear % 2 != 0;
      if ("EVEN_YEARS".equals (sEvery))
        return nYear % 2 == 0;

      if (aHoliday.getValidFrom () != null)
      {
        int nCycleYears = 0;
        if ("2_YEARS".equalsIgnoreCase (sEvery))
          nCycleYears = 2;
        else
          if ("3_YEARS".equalsIgnoreCase (sEvery))
            nCycleYears = 3;
          else
            if ("4_YEARS".equalsIgnoreCase (sEvery))
              nCycleYears = 4;
            else
              if ("5_YEARS".equalsIgnoreCase (sEvery))
                nCycleYears = 5;
              else
                if ("6_YEARS".equalsIgnoreCase (sEvery))
                  nCycleYears = 6;
                else
                  throw new IllegalArgumentException ("Cannot handle unknown cycle type '" + sEvery + "'.");

        return (nYear - aHoliday.getValidFrom ().intValue ()) % nCycleYears == 0;
      }
    }
    return true;
  }
1329174
public function containsPeriod(PeriodInterface $period)
    {
        return $this->contains($period->getBegin()) && $this->contains($period->getEnd());
    }
885409
@Override
	public boolean validate(final Problems problems, final String compName, final String s) {
		if (s.startsWith(".") || s.endsWith(".")) { // NOI18N
			problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "HOST_STARTS_OR_ENDS_WITH_PERIOD", s)); // NOI18N
			return false;
		}
		if (s.indexOf(" ") >= 0 || s.indexOf("\t") >= 0) {
			problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "IP_ADDRESS_CONTAINS_WHITESPACE", compName, s)); // NOI18N
			return false;
		}
		final String[] parts = s.split("\\.");
		if (parts.length > 4) {
			problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "TOO_MANY_LABELS", s)); // NOI18N
			return false;
		}
		for (int i = 0; i < parts.length; i++) {
			final String part = parts[i];
			if (i == parts.length - 1 && part.indexOf(":") > 0) { // NOI18N
				final String[] pts = part.split(":"); // NOI18N
				try {
					final int addr = Integer.parseInt(pts[0]);
					if (addr < 0) {
						problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "ADDR_PART_NEGATIVE", pts[1])); // NOI18N
						return false;
					}
					if (addr > 256) {
						problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "ADDR_PART_HIGH", pts[1])); // NOI18N
						return false;
					}
				} catch (final NumberFormatException e) {
					problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "ADDR_PART_BAD", pts.length >= 2 ? pts[1] : "''")); // NOI18N
					return false;
				}
				if (pts.length == 2 && pts[1].length() == 0) {
					problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "INVALID_PORT", compName, "")); // NOI18N
					return false;
				}
				if (pts.length > 1) {
					try {
						final int port = Integer.parseInt(pts[1]);
						if (port < 0) {
							problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "NEGATIVE_PORT", pts[1])); // NOI18N
							return false;
						} else if (port >= 65536) {
							problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "PORT_TOO_HIGH", pts[1])); // NOI18N
							return false;
						}
					} catch (final NumberFormatException e) {
						problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "INVALID_PORT", compName, pts[1])); // NOI18N
						return false;
					}
				}
			} else {
				try {
					final int addr = Integer.parseInt(part);
					if (addr < 0) {
						problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "ADDR_PART_NEGATIVE", part)); // NOI18N
						return false;
					}
					if (addr > 256) {
						problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "ADDR_PART_HIGH", part)); // NOI18N
						return false;
					}
				} catch (final NumberFormatException e) {
					problems.add(ValidationBundle.getMessage(IpAddressValidator.class, "ADDR_PART_BAD", part)); // NOI18N
					return false;
				}
			}
		}
		return true;
	}
492172
def is_valid_interval(interval):
    
    if not isinstance(interval, (int, long)):
        return False

    if interval <= 0:
        return False

    return True
218087
public boolean isValid() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "Checking validity of token " + this.getClass().getName());

        if (token != null) {
            // return if this token is still valid
            long currentTime = System.currentTimeMillis();
            long expiration = getExpiration();
            long timeleft = expiration - currentTime;

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Time left for token: " + timeleft);

            if (timeleft > 0) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(tc, "token is valid.");
                return true;
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(tc, "token is invalid.");
                return false;
            }
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "token is null, returning invalid.");
            return false;
        }
    }
355125
@Override
	public boolean isValid() {
		Boolean valid = _valid;
		if (valid == null) {
			valid = _chromosomes.forAll(Verifiable::isValid);
			_valid = valid;
		}

		return _valid;
	}