Tabnine Logo
RedisZSetCommands$Range$Boundary
Code IndexAdd Tabnine to your IDE (free)

How to use
RedisZSetCommands$Range$Boundary
in
org.springframework.data.redis.connection

Best Java code snippets using org.springframework.data.redis.connection.RedisZSetCommands$Range$Boundary (Showing top 20 results out of 315)

origin: spring-projects/spring-data-redis

private static Converter<org.springframework.data.redis.connection.RedisZSetCommands.Range, Range.Boundary<?>> rangeToBoundaryArgumentConverter(
    boolean upper, boolean convertNumberToBytes) {
  return (source) -> {
    Boundary sourceBoundary = upper ? source.getMax() : source.getMin();
    if (sourceBoundary == null || sourceBoundary.getValue() == null) {
      return Range.Boundary.unbounded();
    }
    boolean inclusive = sourceBoundary.isIncluding();
    Object value = sourceBoundary.getValue();
    if (value instanceof Number) {
      if (convertNumberToBytes) {
        value = value.toString();
      } else {
        return inclusive ? Range.Boundary.including((Number) value) : Range.Boundary.excluding((Number) value);
      }
    }
    if (value instanceof String) {
      if (!StringUtils.hasText((String) value) || ObjectUtils.nullSafeEquals(value, "+")
          || ObjectUtils.nullSafeEquals(value, "-")) {
        return Range.Boundary.unbounded();
      }
      return inclusive ? Range.Boundary.including(value.toString().getBytes(LettuceCharsets.UTF8))
          : Range.Boundary.excluding(value.toString().getBytes(LettuceCharsets.UTF8));
    }
    return inclusive ? Range.Boundary.including((byte[]) value) : Range.Boundary.excluding((byte[]) value);
  };
}
origin: spring-projects/spring-data-redis

/**
 * Less Then Equals
 *
 * @param max must not be {@literal null}.
 * @return this.
 */
public Range lte(Object max) {
  Assert.notNull(max, "Max already set for range.");
  this.max = new Boundary(max, true);
  return this;
}
origin: apache/servicemix-bundles

private static Converter<org.springframework.data.redis.connection.RedisZSetCommands.Range, Range.Boundary<?>> rangeToBoundaryArgumentConverter(
    boolean upper) {
  return (source) -> {
    Boundary sourceBoundary = upper ? source.getMax() : source.getMin();
    if (sourceBoundary == null || sourceBoundary.getValue() == null) {
      return Range.Boundary.unbounded();
    }
    boolean inclusive = sourceBoundary.isIncluding();
    Object value = sourceBoundary.getValue();
    if (value instanceof Number) {
      return inclusive ? Range.Boundary.including((Number) value) : Range.Boundary.excluding((Number) value);
    }
    if (value instanceof String) {
      if (!StringUtils.hasText((String) value) || ObjectUtils.nullSafeEquals(value, "+")
          || ObjectUtils.nullSafeEquals(value, "-")) {
        return Range.Boundary.unbounded();
      }
      return inclusive ? Range.Boundary.including(value.toString().getBytes(LettuceCharsets.UTF8))
          : Range.Boundary.excluding(value.toString().getBytes(LettuceCharsets.UTF8));
    }
    return inclusive ? Range.Boundary.including((byte[]) value) : Range.Boundary.excluding((byte[]) value);
  };
}
origin: apache/servicemix-bundles

private static byte[] boundaryToBytes(Boundary boundary, byte[] inclPrefix, byte[] exclPrefix) {
  byte[] prefix = boundary.isIncluding() ? inclPrefix : exclPrefix;
  byte[] value = null;
  if (boundary.getValue() instanceof byte[]) {
    value = (byte[]) boundary.getValue();
  } else if (boundary.getValue() instanceof Double) {
    value = toBytes((Double) boundary.getValue());
  } else if (boundary.getValue() instanceof Long) {
    value = toBytes((Long) boundary.getValue());
  } else if (boundary.getValue() instanceof Integer) {
    value = toBytes((Integer) boundary.getValue());
  } else if (boundary.getValue() instanceof String) {
    value = toBytes((String) boundary.getValue());
  } else {
    throw new IllegalArgumentException(String.format("Cannot convert %s to binary format", boundary.getValue()));
  }
  ByteBuffer buffer = ByteBuffer.allocate(prefix.length + value.length);
  buffer.put(prefix);
  buffer.put(value);
  return buffer.array();
}
origin: apache/servicemix-bundles

private static String boundaryToBytes(Boundary boundary, byte[] inclPrefix, byte[] exclPrefix) {
  byte[] prefix = boundary.isIncluding() ? inclPrefix : exclPrefix;
  byte[] value = null;
  if (boundary.getValue() instanceof byte[]) {
    value = (byte[]) boundary.getValue();
  } else if (boundary.getValue() instanceof Double) {
    value = toBytes((Double) boundary.getValue());
  } else if (boundary.getValue() instanceof Long) {
    value = toBytes((Long) boundary.getValue());
  } else if (boundary.getValue() instanceof Integer) {
    value = toBytes((Integer) boundary.getValue());
  } else if (boundary.getValue() instanceof String) {
    value = toBytes((String) boundary.getValue());
  } else {
    throw new IllegalArgumentException(String.format("Cannot convert %s to binary format", boundary.getValue()));
  }
  ByteBuffer buffer = ByteBuffer.allocate(prefix.length + value.length);
  buffer.put(prefix);
  buffer.put(value);
  return toString(ByteUtils.getBytes(buffer));
}
origin: org.springframework.data/spring-data-redis

private static Converter<org.springframework.data.redis.connection.RedisZSetCommands.Range, Range.Boundary<?>> rangeToBoundaryArgumentConverter(
    boolean upper) {
  return (source) -> {
    Boundary sourceBoundary = upper ? source.getMax() : source.getMin();
    if (sourceBoundary == null || sourceBoundary.getValue() == null) {
      return Range.Boundary.unbounded();
    }
    boolean inclusive = sourceBoundary.isIncluding();
    Object value = sourceBoundary.getValue();
    if (value instanceof Number) {
      return inclusive ? Range.Boundary.including((Number) value) : Range.Boundary.excluding((Number) value);
    }
    if (value instanceof String) {
      if (!StringUtils.hasText((String) value) || ObjectUtils.nullSafeEquals(value, "+")
          || ObjectUtils.nullSafeEquals(value, "-")) {
        return Range.Boundary.unbounded();
      }
      return inclusive ? Range.Boundary.including(value.toString().getBytes(LettuceCharsets.UTF8))
          : Range.Boundary.excluding(value.toString().getBytes(LettuceCharsets.UTF8));
    }
    return inclusive ? Range.Boundary.including((byte[]) value) : Range.Boundary.excluding((byte[]) value);
  };
}
origin: org.springframework.data/spring-data-redis

private static byte[] boundaryToBytes(Boundary boundary, byte[] inclPrefix, byte[] exclPrefix) {
  byte[] prefix = boundary.isIncluding() ? inclPrefix : exclPrefix;
  byte[] value = null;
  if (boundary.getValue() instanceof byte[]) {
    value = (byte[]) boundary.getValue();
  } else if (boundary.getValue() instanceof Double) {
    value = toBytes((Double) boundary.getValue());
  } else if (boundary.getValue() instanceof Long) {
    value = toBytes((Long) boundary.getValue());
  } else if (boundary.getValue() instanceof Integer) {
    value = toBytes((Integer) boundary.getValue());
  } else if (boundary.getValue() instanceof String) {
    value = toBytes((String) boundary.getValue());
  } else {
    throw new IllegalArgumentException(String.format("Cannot convert %s to binary format", boundary.getValue()));
  }
  ByteBuffer buffer = ByteBuffer.allocate(prefix.length + value.length);
  buffer.put(prefix);
  buffer.put(value);
  return buffer.array();
}
origin: org.springframework.data/spring-data-redis

private static String boundaryToBytes(Boundary boundary, byte[] inclPrefix, byte[] exclPrefix) {
  byte[] prefix = boundary.isIncluding() ? inclPrefix : exclPrefix;
  byte[] value = null;
  if (boundary.getValue() instanceof byte[]) {
    value = (byte[]) boundary.getValue();
  } else if (boundary.getValue() instanceof Double) {
    value = toBytes((Double) boundary.getValue());
  } else if (boundary.getValue() instanceof Long) {
    value = toBytes((Long) boundary.getValue());
  } else if (boundary.getValue() instanceof Integer) {
    value = toBytes((Integer) boundary.getValue());
  } else if (boundary.getValue() instanceof String) {
    value = toBytes((String) boundary.getValue());
  } else {
    throw new IllegalArgumentException(String.format("Cannot convert %s to binary format", boundary.getValue()));
  }
  ByteBuffer buffer = ByteBuffer.allocate(prefix.length + value.length);
  buffer.put(prefix);
  buffer.put(value);
  return toString(ByteUtils.getBytes(buffer));
}
origin: apache/servicemix-bundles

/**
 * Converts a given {@link Boundary} to its binary representation suitable for {@literal ZRANGEBY*} commands, despite
 * {@literal ZRANGEBYLEX}.
 *
 * @param boundary
 * @param defaultValue
 * @return
 * @since 1.6
 */
public static byte[] boundaryToBytesForZRange(@Nullable Boundary boundary, byte[] defaultValue) {
  if (boundary == null || boundary.getValue() == null) {
    return defaultValue;
  }
  return boundaryToBytes(boundary, new byte[] {}, toBytes("("));
}
origin: apache/servicemix-bundles

/**
 * Converts a given {@link Boundary} to its binary representation suitable for {@literal ZRANGEBY*} commands, despite
 * {@literal ZRANGEBYLEX}.
 *
 * @param boundary
 * @param defaultValue
 * @return
 * @since 1.6
 */
public static String boundaryToBytesForZRange(Boundary boundary, byte[] defaultValue) {
  if (boundary == null || boundary.getValue() == null) {
    return toString(defaultValue);
  }
  return boundaryToBytes(boundary, new byte[] {}, toBytes("("));
}
origin: org.springframework.data/spring-data-redis

/**
 * Converts a given {@link Boundary} to its binary representation suitable for {@literal ZRANGEBY*} commands, despite
 * {@literal ZRANGEBYLEX}.
 *
 * @param boundary
 * @param defaultValue
 * @return
 * @since 1.6
 */
public static byte[] boundaryToBytesForZRange(@Nullable Boundary boundary, byte[] defaultValue) {
  if (boundary == null || boundary.getValue() == null) {
    return defaultValue;
  }
  return boundaryToBytes(boundary, new byte[] {}, toBytes("("));
}
origin: apache/servicemix-bundles

static Boundary infinite() {
  return new Boundary(null, true);
}
origin: apache/servicemix-bundles

/**
 * Converts a given {@link Boundary} to its binary representation suitable for ZRANGEBYLEX command.
 *
 * @param boundary
 * @return
 * @since 1.6
 */
public static byte[] boundaryToBytesForZRangeByLex(@Nullable Boundary boundary, byte[] defaultValue) {
  if (boundary == null || boundary.getValue() == null) {
    return defaultValue;
  }
  return boundaryToBytes(boundary, toBytes("["), toBytes("("));
}
origin: org.springframework.data/spring-data-redis

/**
 * Converts a given {@link Boundary} to its binary representation suitable for {@literal ZRANGEBY*} commands, despite
 * {@literal ZRANGEBYLEX}.
 *
 * @param boundary
 * @param defaultValue
 * @return
 * @since 1.6
 */
public static String boundaryToBytesForZRange(Boundary boundary, byte[] defaultValue) {
  if (boundary == null || boundary.getValue() == null) {
    return toString(defaultValue);
  }
  return boundaryToBytes(boundary, new byte[] {}, toBytes("("));
}
origin: org.springframework.data/spring-data-redis

static Boundary infinite() {
  return new Boundary(null, true);
}
origin: apache/servicemix-bundles

public static String boundaryToStringForZRange(Boundary boundary, String defaultValue) {
  if (boundary == null || boundary.getValue() == null) {
    return defaultValue;
  }
  return boundaryToString(boundary, "", "(");
}
origin: org.springframework.data/spring-data-redis

/**
 * Converts a given {@link Boundary} to its binary representation suitable for ZRANGEBYLEX command.
 *
 * @param boundary
 * @return
 * @since 1.6
 */
public static byte[] boundaryToBytesForZRangeByLex(@Nullable Boundary boundary, byte[] defaultValue) {
  if (boundary == null || boundary.getValue() == null) {
    return defaultValue;
  }
  return boundaryToBytes(boundary, toBytes("["), toBytes("("));
}
origin: apache/servicemix-bundles

/**
 * Converts a given {@link Boundary} to its binary representation suitable for ZRANGEBYLEX command.
 *
 * @param boundary
 * @return
 * @since 1.6
 */
public static String boundaryToBytesForZRangeByLex(Boundary boundary, byte[] defaultValue) {
  if (boundary == null || boundary.getValue() == null) {
    return toString(defaultValue);
  }
  return boundaryToBytes(boundary, toBytes("["), toBytes("("));
}
origin: apache/servicemix-bundles

/**
 * Greater Than Equals
 *
 * @param min must not be {@literal null}.
 * @return this.
 */
public Range gte(Object min) {
  Assert.notNull(min, "Min already set for range.");
  this.min = new Boundary(min, true);
  return this;
}
origin: apache/servicemix-bundles

/**
 * @return new {@link Range} with {@literal min} and {@literal max} set to {@link Boundary#infinite()}.
 */
public static Range unbounded() {
  Range range = new Range();
  range.min = Boundary.infinite();
  range.max = Boundary.infinite();
  return range;
}
org.springframework.data.redis.connectionRedisZSetCommands$Range$Boundary

Most used methods

  • getValue
  • isIncluding
  • <init>
  • infinite

Popular in Java

  • Start an intent from android
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
  • putExtra (Intent)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • CodeWhisperer alternatives
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