private OrderLine getRequiredOrderLineByIndex(int index) { Range<Integer> allowedIndexRange = Range.from(Bound.inclusive(0))// .to(Bound.exclusive(orderLines.size())); Assert.isTrue(allowedIndexRange.contains(index), String.format("Invalid order line index %s. Required: %s!", index, allowedIndexRange)); return this.orderLines.get(index); }
/** * Creates a new {@link QuotationMap} for the query. * * @param query can be {@literal null}. */ public QuotationMap(@Nullable String query) { if (query == null) { return; } Character inQuotation = null; int start = 0; for (int i = 0; i < query.length(); i++) { char currentChar = query.charAt(i); if (QUOTING_CHARACTERS.contains(currentChar)) { if (inQuotation == null) { inQuotation = currentChar; start = i; } else if (currentChar == inQuotation) { inQuotation = null; quotedRanges.add(Range.from(Bound.inclusive(start)).to(Bound.inclusive(i))); } } } if (inQuotation != null) { throw new IllegalArgumentException( String.format("The string <%s> starts a quoted range at %d, but never ends it.", query, start)); } }
/** * Creates a {@link Range} between the given {@link Distance}. * * @param min can be {@literal null}. * @param max can be {@literal null}. * @return will never be {@literal null}. */ public static Range<Distance> between(Distance min, Distance max) { return Range.from(Bound.inclusive(min)).to(Bound.inclusive(max)); }