List of usage examples for org.apache.commons.lang.math Range containsInteger
public boolean containsInteger(int value)
Tests whether the specified int occurs within this range using int comparison.
This implementation uses the #getMinimumInteger() and #getMaximumInteger() methods and should be good for most uses.
From source file:org.jtalks.jcommune.model.validation.validators.PollItemsNamesLengthValidator.java
/** * Validates the name of poll title.// w w w . j a va 2 s . c o m * * @param pollItem validated poll item * @return {@code true} if poll item name has correct length, * otherwise {@code false} */ private boolean isPollItemValid(PollItem pollItem) { String pollItemName = pollItem.getName(); Range range = new IntRange(minLength, maxLenght); int pollItemLength = pollItemName.length(); return range.containsInteger(pollItemLength); }
From source file:org.jtalks.jcommune.model.validation.validators.PollItemsSizeValidator.java
/** * {@inheritDoc}/*from www .j a va 2s . c om*/ */ @Override public boolean isValid(List<PollItem> pollItems, ConstraintValidatorContext context) { if (!CollectionUtils.isEmpty(pollItems)) { Range range = new IntRange(minSize, maxSize); return range.containsInteger(pollItems.size()); } return true; }
From source file:org.osframework.contract.date.fincal.holiday.producer.SingleFinancialCalendarProducer.java
public Holiday[] produce(Integer... years) { Arrays.sort(years);// w w w. j a v a 2 s . co m Range yearRange = new IntRange(years[0], years[years.length - 1]); List<Holiday> holidays = new LinkedList<Holiday>(); for (int year = yearRange.getMinimumInteger(); yearRange.containsInteger(year); year++) { for (HolidayDefinition hd : calendar) { HolidayExpression expr = CentralBankDecoratorLocator.decorate(hd, calendar.getCentralBank()); Date date = expr.evaluate(year); holidays.add(new Holiday(calendar, date, hd)); } if (weekendsAsHolidays) { this.addWeekends(year, holidays); } } return holidays.toArray(EMPTY_ARRAY); }