All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.lettuce.core.LPosArgs Maven / Gradle / Ivy

Go to download

Advanced and thread-safe Java Redis client for synchronous, asynchronous, and reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs and much more.

The newest version!
package io.lettuce.core;

import io.lettuce.core.internal.LettuceAssert;
import io.lettuce.core.protocol.CommandArgs;
import io.lettuce.core.protocol.CommandKeyword;

/**
 * Argument list builder for the Redis LPOS command. Static import the methods from
 * {@link Builder} and call the methods: {@code maxlen(…)} .
 * 

* {@link LPosArgs} is a mutable object and instances should be used only once to avoid shared mutable state. * * @author Mark Paluch * @since 5.3.2 */ public class LPosArgs implements CompositeArgument { private Long rank; private Long maxlen; /** * Builder entry points for {@link LPosArgs}. */ public static class Builder { /** * Utility constructor. */ private Builder() { } /** * Creates new empty {@link LPosArgs}. * * @return new {@link LPosArgs}. * @see LPosArgs#maxlen(long) */ public static LPosArgs empty() { return new LPosArgs(); } /** * Creates new {@link LPosArgs} and setting {@literal MAXLEN}. * * @return new {@link LPosArgs} with {@literal MAXLEN} set. * @see LPosArgs#maxlen(long) */ public static LPosArgs maxlen(long count) { return new LPosArgs().maxlen(count); } /** * Creates new {@link LPosArgs} and setting {@literal RANK}. * * @return new {@link LPosArgs} with {@literal RANK} set. * @see LPosArgs#rank(long) */ public static LPosArgs rank(long rank) { return new LPosArgs().rank(rank); } } /** * Limit list scanning to {@code maxlen} entries. * * @param maxlen number greater 0. * @return {@code this} */ public LPosArgs maxlen(long maxlen) { LettuceAssert.isTrue(maxlen > 0, "Maxlen must be greater 0"); this.maxlen = maxlen; return this; } /** * Specify the rank of the first element to return, in case there are multiple matches. * * @param rank number. * @return {@code this} */ public LPosArgs rank(long rank) { this.rank = rank; return this; } @Override public void build(CommandArgs args) { if (maxlen != null) { args.add(CommandKeyword.MAXLEN); args.add(maxlen); } if (rank != null) { args.add("RANK"); args.add(rank); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy