private static Bound<?> createBound(Number number, boolean inclusive) { if (number instanceof Long) { return inclusive ? Bound.inclusive((Long) number) : Bound.exclusive((Long) number); } if (number instanceof Double) { return inclusive ? Bound.inclusive((Double) number) : Bound.exclusive((Double) number); } if (number instanceof Float) { return inclusive ? Bound.inclusive((Float) number) : Bound.exclusive((Float) number); } if (number instanceof Integer) { return inclusive ? Bound.inclusive((Integer) number) : Bound.exclusive((Integer) number); } if (number instanceof BigDecimal) { return inclusive ? Bound.inclusive((BigDecimal) number) : Bound.exclusive((BigDecimal) number); } throw new IllegalArgumentException("Unsupported numeric value."); }
private static Bound<?> createBound(Number number, boolean inclusive) { if (number instanceof Long) { return inclusive ? Bound.inclusive((Long) number) : Bound.exclusive((Long) number); } if (number instanceof Double) { return inclusive ? Bound.inclusive((Double) number) : Bound.exclusive((Double) number); } if (number instanceof Float) { return inclusive ? Bound.inclusive((Float) number) : Bound.exclusive((Float) number); } if (number instanceof Integer) { return inclusive ? Bound.inclusive((Integer) number) : Bound.exclusive((Integer) number); } if (number instanceof BigDecimal) { return inclusive ? Bound.inclusive((BigDecimal) number) : Bound.exclusive((BigDecimal) number); } throw new IllegalArgumentException("Unsupported numeric value."); }
/** * Applies an upper bound to the {@link Range}. Constructs a new command instance with all previously configured * properties. * * @param end * @return a new {@link RangeCommand} with the upper bound applied. */ public RangeCommand toIndex(long end) { return new RangeCommand(getKey(), Range.of(range.getLowerBound(), Bound.inclusive(end))); }
/** * Applies a lower bound to the {@link Range}. Constructs a new command instance with all previously configured * properties. * * @param start * @return a new {@link RangeCommand} with the lower bound applied. */ public RangeCommand fromIndex(long start) { return new RangeCommand(getKey(), Range.of(Bound.inclusive(start), range.getUpperBound())); }
/** * Define the {@literal maxItems}. * * @param count the allowed maximal number of array items. * @return new instance of {@link ArrayJsonSchemaObject}. */ public ArrayJsonSchemaObject maxItems(int count) { Bound<Integer> lower = this.range != null ? this.range.getLowerBound() : Bound.unbounded(); return range(Range.of(lower, Bound.inclusive(count))); }
/** * Define the valid length range ({@literal maxLength}) for a valid field. * * @param length * @return new instance of {@link StringJsonSchemaObject}. */ public StringJsonSchemaObject maxLength(int length) { Bound<Integer> lower = this.length != null ? this.length.getLowerBound() : Bound.unbounded(); return length(Range.of(lower, Bound.inclusive(length))); }
/** * Define the {@literal minProperties}. * * @param count the allowed minimal number of properties. * @return new instance of {@link ObjectJsonSchemaObject}. */ public ObjectJsonSchemaObject minProperties(int count) { Bound<Integer> upper = this.propertiesCount != null ? this.propertiesCount.getUpperBound() : Bound.unbounded(); return propertiesCount(Range.of(Bound.inclusive(count), upper)); }
public Range<Distance> getDistanceRange() { MongoParameters mongoParameters = method.getParameters(); int rangeIndex = mongoParameters.getRangeIndex(); if (rangeIndex != -1) { return getValue(rangeIndex); } int maxDistanceIndex = mongoParameters.getMaxDistanceIndex(); Bound<Distance> maxDistance = maxDistanceIndex == -1 ? Bound.unbounded() : Bound.inclusive((Distance) getValue(maxDistanceIndex)); return Range.of(Bound.unbounded(), maxDistance); }
/** * Define the valid length range ({@literal minLength}) for a valid field. * * @param length * @return new instance of {@link StringJsonSchemaObject}. */ public StringJsonSchemaObject minLength(int length) { Bound<Integer> upper = this.length != null ? this.length.getUpperBound() : Bound.unbounded(); return length(Range.of(Bound.inclusive(length), upper)); }
/** * Define the {@literal maxProperties}. * * @param count the allowed maximum number of properties. * @return new instance of {@link ObjectJsonSchemaObject}. */ public ObjectJsonSchemaObject maxProperties(int count) { Bound<Integer> lower = this.propertiesCount != null ? this.propertiesCount.getLowerBound() : Bound.unbounded(); return propertiesCount(Range.of(lower, Bound.inclusive(count))); }
/** * Define the {@literal maxItems}. * * @param count the allowed minimal number of array items. * @return new instance of {@link ArrayJsonSchemaObject}. */ public ArrayJsonSchemaObject minItems(int count) { Bound<Integer> upper = this.range != null ? this.range.getUpperBound() : Bound.unbounded(); return range(Range.of(Bound.inclusive(count), upper)); }
/** * Define the {@literal maxItems}. * * @param count the allowed maximal number of array items. * @return new instance of {@link ArrayJsonSchemaObject}. */ public ArrayJsonSchemaObject maxItems(int count) { Bound<Integer> lower = this.range != null ? this.range.getLowerBound() : Bound.unbounded(); return range(Range.of(lower, Bound.inclusive(count))); }
/** * Define the {@literal maxProperties}. * * @param count the allowed maximum number of properties. * @return new instance of {@link ObjectJsonSchemaObject}. */ public ObjectJsonSchemaObject maxProperties(int count) { Bound<Integer> lower = this.propertiesCount != null ? this.propertiesCount.getLowerBound() : Bound.unbounded(); return propertiesCount(Range.of(lower, Bound.inclusive(count))); }
/** * Applies an upper bound to the {@link Range}. Constructs a new command instance with all previously configured * properties. * * @param end * @return a new {@link RangeCommand} with the upper bound applied. */ public RangeCommand toIndex(long end) { return new RangeCommand(getKey(), Range.of(range.getLowerBound(), Bound.inclusive(end))); }
/** * Define the valid length range ({@literal minLength}) for a valid field. * * @param length * @return new instance of {@link StringJsonSchemaObject}. */ public StringJsonSchemaObject minLength(int length) { Bound<Integer> upper = this.length != null ? this.length.getUpperBound() : Bound.unbounded(); return length(Range.of(Bound.inclusive(length), upper)); }
/** * Applies a lower bound to the {@link Range}. Constructs a new command instance with all previously configured * properties. * * @param start * @return a new {@link RangeCommand} with the lower bound applied. */ public RangeCommand fromIndex(long start) { return new RangeCommand(getKey(), Range.of(Bound.inclusive(start), range.getUpperBound())); }
public Range<Distance> getDistanceRange() { MongoParameters mongoParameters = method.getParameters(); int rangeIndex = mongoParameters.getRangeIndex(); if (rangeIndex != -1) { return getValue(rangeIndex); } int maxDistanceIndex = mongoParameters.getMaxDistanceIndex(); Bound<Distance> maxDistance = maxDistanceIndex == -1 ? Bound.unbounded() : Bound.inclusive((Distance) getValue(maxDistanceIndex)); return Range.of(Bound.unbounded(), maxDistance); }
/** * Define the {@literal maxItems}. * * @param count the allowed minimal number of array items. * @return new instance of {@link ArrayJsonSchemaObject}. */ public ArrayJsonSchemaObject minItems(int count) { Bound<Integer> upper = this.range != null ? this.range.getUpperBound() : Bound.unbounded(); return range(Range.of(Bound.inclusive(count), upper)); }
/** * Define the valid length range ({@literal maxLength}) for a valid field. * * @param length * @return new instance of {@link StringJsonSchemaObject}. */ public StringJsonSchemaObject maxLength(int length) { Bound<Integer> lower = this.length != null ? this.length.getLowerBound() : Bound.unbounded(); return length(Range.of(lower, Bound.inclusive(length))); }
/** * Define the {@literal minProperties}. * * @param count the allowed minimal number of properties. * @return new instance of {@link ObjectJsonSchemaObject}. */ public ObjectJsonSchemaObject minProperties(int count) { Bound<Integer> upper = this.propertiesCount != null ? this.propertiesCount.getUpperBound() : Bound.unbounded(); return propertiesCount(Range.of(Bound.inclusive(count), upper)); }