Tabnine Logo
Range.getLowerBound
Code IndexAdd Tabnine to your IDE (free)

How to use
getLowerBound
method
in
org.springframework.data.domain.Range

Best Java code snippets using org.springframework.data.domain.Range.getLowerBound (Showing top 20 results out of 315)

origin: spring-projects/spring-data-redis

  private static <T extends Comparable<T>> T getLowerValue(Range<T> range) {
    return range.getLowerBound().getValue()
        .orElseThrow(() -> new IllegalArgumentException("Range does not contain lower bound value!"));
  }
}
origin: spring-projects/spring-data-redis

/**
 * Return {@link Optional} lower bound from {@link Range}.
 *
 * @param range
 * @param <T>
 * @return
 * @since 2.0.9
 */
static <T extends Comparable<T>> Optional<T> getLowerBound(org.springframework.data.domain.Range<T> range) {
  return range.getLowerBound().getValue();
}
origin: spring-projects/spring-data-redis

  private static <T extends Comparable<T>> T getLowerValue(Range<T> range) {
    return range.getLowerBound().getValue()
        .orElseThrow(() -> new IllegalArgumentException("Range does not contain lower bound value!"));
  }
}
origin: spring-projects/spring-data-mongodb

  /**
   * Converts the given {@link Range} into an array of values.
   *
   * @param range must not be {@literal null}.
   * @return
   */
  public static List<Long> toRangeValues(Range<Long> range) {

    Assert.notNull(range, "Range must not be null!");

    List<Long> result = new ArrayList<Long>(2);
    result.add(range.getLowerBound().getValue()
        .orElseThrow(() -> new IllegalArgumentException("Lower bound of range must be bounded!")));
    range.getUpperBound().getValue().ifPresent(it -> result.add(it));

    return result;
  }
}
origin: spring-projects/spring-data-redis

@Override
public Long bitPos(byte[] key, boolean bit, Range<Long> range) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(range, "Range must not be null! Use Range.unbounded() instead.");
  List<byte[]> args = new ArrayList<>(3);
  args.add(LettuceConverters.toBit(bit));
  if (range.getLowerBound().isBounded()) {
    args.add(range.getLowerBound().getValue().map(LettuceConverters::toBytes).get());
  }
  if (range.getUpperBound().isBounded()) {
    args.add(range.getUpperBound().getValue().map(LettuceConverters::toBytes).get());
  }
  return Long.class.cast(connection.execute("BITPOS", key, args));
}
origin: spring-projects/spring-data-mongodb

@Override
public Document toDocument() {
  Document doc = new Document(super.toDocument());
  if (!CollectionUtils.isEmpty(items)) {
    doc.append("items", items.size() == 1 ? items.iterator().next()
        : items.stream().map(JsonSchemaObject::toDocument).collect(Collectors.toList()));
  }
  if (range != null) {
    range.getLowerBound().getValue().ifPresent(it -> doc.append("minItems", it));
    range.getUpperBound().getValue().ifPresent(it -> doc.append("maxItems", it));
  }
  if (ObjectUtils.nullSafeEquals(uniqueItems, Boolean.TRUE)) {
    doc.append("uniqueItems", true);
  }
  if (additionalItems != null) {
    doc.append("additionalItems", additionalItems);
  }
  return doc;
}
origin: spring-projects/spring-data-mongodb

/**
 * Set {@literal maximum} to given {@code max} value and {@literal exclusiveMaximum} to {@literal false}.
 *
 * @param max must not be {@literal null}.
 * @return new instance of {@link NumericJsonSchemaObject}.
 */
@SuppressWarnings("unchecked")
NumericJsonSchemaObject lte(Number max) {
  Assert.notNull(max, "Max must not be null!");
  Bound lower = this.range != null ? this.range.getLowerBound() : Bound.unbounded();
  return within(Range.of(lower, createBound(max, true)));
}
origin: spring-projects/spring-data-mongodb

/**
 * Set {@literal maximum} to given {@code max} value and {@literal exclusiveMaximum} to {@literal true}.
 *
 * @param max must not be {@literal null}.
 * @return new instance of {@link NumericJsonSchemaObject}.
 */
@SuppressWarnings("unchecked")
public NumericJsonSchemaObject lt(Number max) {
  Assert.notNull(max, "Max must not be null!");
  Bound lower = this.range != null ? this.range.getLowerBound() : Bound.unbounded();
  return within(Range.of(lower, createBound(max, false)));
}
origin: spring-projects/spring-data-mongodb

@Override
public Document toDocument() {
  Document doc = new Document(super.toDocument());
  if (length != null) {
    length.getLowerBound().getValue().ifPresent(it -> doc.append("minLength", it));
    length.getUpperBound().getValue().ifPresent(it -> doc.append("maxLength", it));
  }
  if (!StringUtils.isEmpty(pattern)) {
    doc.append("pattern", pattern);
  }
  return doc;
}
origin: spring-projects/spring-data-redis

/**
 * 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)));
}
origin: spring-projects/spring-data-mongodb

/**
 * 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)));
}
origin: spring-projects/spring-data-mongodb

/**
 * 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)));
}
origin: spring-projects/spring-data-mongodb

/**
 * 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)));
}
origin: spring-projects/spring-data-redis

Boolean inclusive = upper ? source.getUpperBound().isInclusive() : source.getLowerBound().isInclusive();
Object value = upper ? source.getUpperBound().getValue().orElse(null)
    : source.getLowerBound().getValue().orElse(null);
origin: spring-projects/spring-data-mongodb

@Override
public Document toDocument() {
  Document doc = new Document(super.toDocument());
  if (multipleOf != null) {
    doc.append("multipleOf", multipleOf);
  }
  if (range != null) {
    if (range.getLowerBound().isBounded()) {
      range.getLowerBound().getValue().ifPresent(it -> doc.append("minimum", it));
      if (!range.getLowerBound().isInclusive()) {
        doc.append("exclusiveMinimum", true);
      }
    }
    if (range.getUpperBound().isBounded()) {
      range.getUpperBound().getValue().ifPresent(it -> doc.append("maximum", it));
      if (!range.getUpperBound().isInclusive()) {
        doc.append("exclusiveMaximum", true);
      }
    }
  }
  return doc;
}
origin: spring-projects/spring-data-mongodb

@Override
public Document toDocument() {
  Document doc = new Document(super.toDocument());
  if (!CollectionUtils.isEmpty(requiredProperties)) {
    doc.append("required", requiredProperties);
  }
  if (propertiesCount != null) {
    propertiesCount.getLowerBound().getValue().ifPresent(it -> doc.append("minProperties", it));
    propertiesCount.getUpperBound().getValue().ifPresent(it -> doc.append("maxProperties", it));
  }
  if (!CollectionUtils.isEmpty(properties)) {
    doc.append("properties", reduceToDocument(properties));
  }
  if (!CollectionUtils.isEmpty(patternProperties)) {
    doc.append("patternProperties", reduceToDocument(patternProperties));
  }
  if (additionalProperties != null) {
    doc.append("additionalProperties", additionalProperties instanceof JsonSchemaObject
        ? ((JsonSchemaObject) additionalProperties).toDocument() : additionalProperties);
  }
  return doc;
}
origin: spring-projects/spring-data-mongodb

@SuppressWarnings({ "unchecked", "rawtypes" })
protected Flux<GeoResult<Object>> doExecuteQuery(@Nullable Query query, Class<?> type, String collection) {
  Point nearLocation = accessor.getGeoNearLocation();
  NearQuery nearQuery = NearQuery.near(nearLocation);
  if (query != null) {
    nearQuery.query(query);
  }
  Range<Distance> distances = accessor.getDistanceRange();
  distances.getUpperBound().getValue().ifPresent(it -> nearQuery.maxDistance(it).in(it.getMetric()));
  distances.getLowerBound().getValue().ifPresent(it -> nearQuery.minDistance(it).in(it.getMetric()));
  Pageable pageable = accessor.getPageable();
  nearQuery.with(pageable);
  return (Flux) operations.geoNear(nearQuery, type, collection);
}
origin: spring-projects/spring-data-redis

@Nullable
@Override
public Long bitPos(byte[] key, boolean bit, Range<Long> range) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(range, "Range must not be null! Use Range.unbounded() instead.");
  BitPosParams params = null;
  if (range.getLowerBound().isBounded()) {
    params = range.getUpperBound().isBounded()
        ? new BitPosParams(range.getLowerBound().getValue().get(), range.getUpperBound().getValue().get())
        : new BitPosParams(range.getLowerBound().getValue().get());
  }
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(params != null ? connection.getRequiredPipeline().bitpos(key, bit, params)
          : connection.getRequiredPipeline().bitpos(key, bit)));
      return null;
    }
    if (isQueueing()) {
      transaction(
          connection.newJedisResult(params != null ? connection.getRequiredTransaction().bitpos(key, bit, params)
              : connection.getRequiredTransaction().bitpos(key, bit)));
      return null;
    }
    return params != null ? connection.getJedis().bitpos(key, bit, params) : connection.getJedis().bitpos(key, bit);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}
origin: spring-projects/spring-data-mongodb

@SuppressWarnings("unchecked")
GeoResults<Object> doExecuteQuery(Query query) {
  Point nearLocation = accessor.getGeoNearLocation();
  NearQuery nearQuery = NearQuery.near(nearLocation);
  if (query != null) {
    nearQuery.query(query);
  }
  Range<Distance> distances = accessor.getDistanceRange();
  distances.getLowerBound().getValue().ifPresent(it -> nearQuery.minDistance(it).in(it.getMetric()));
  distances.getUpperBound().getValue().ifPresent(it -> nearQuery.maxDistance(it).in(it.getMetric()));
  Pageable pageable = accessor.getPageable();
  nearQuery.with(pageable);
  return (GeoResults<Object>) operation.near(nearQuery).all();
}
origin: spring-projects/spring-data-redis

@Override
public Flux<NumericResponse<BitPosCommand, Long>> bitPos(Publisher<BitPosCommand> commands) {
  return connection.execute(cmd -> {
    return Flux.from(commands).flatMap(command -> {
      Mono<Long> result;
      Range<Long> range = command.getRange();
      if (range.getLowerBound().isBounded()) {
        result = cmd.bitpos(command.getKey(), command.getBit(), getLowerValue(range));
        if (range.getUpperBound().isBounded()) {
          result = cmd.bitpos(command.getKey(), command.getBit(), getLowerValue(range), getUpperValue(range));
        }
      } else {
        result = cmd.bitpos(command.getKey(), command.getBit());
      }
      return result.map(respValue -> new NumericResponse<>(command, respValue));
    });
  });
}
org.springframework.data.domainRangegetLowerBound

Popular methods of Range

  • <init>
  • getUpperBound
  • of
  • contains
    Returns whether the Range contains the given value.
  • equals
  • from
    Create a RangeBuilder given the lower Bound.
  • unbounded

Popular in Java

  • Making http post requests using okhttp
  • putExtra (Intent)
  • getContentResolver (Context)
  • findViewById (Activity)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Permission (java.security)
    Legacy security code; do not use.
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now