Skip to content

Commit

Permalink
Polishing #1285
Browse files Browse the repository at this point in the history
Reformat code. Forward existing match(…) implementation to new method. Add since and author tags.
  • Loading branch information
mp911de committed Jun 8, 2020
1 parent e283b42 commit 4f9d330
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/main/java/io/lettuce/core/ScanArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
import static io.lettuce.core.protocol.CommandKeyword.COUNT;
import static io.lettuce.core.protocol.CommandKeyword.MATCH;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import io.lettuce.core.codec.StringCodec;
import io.lettuce.core.internal.LettuceAssert;
import io.lettuce.core.protocol.CommandArgs;

Expand All @@ -34,6 +32,7 @@
* {@link ScanArgs} is a mutable object and instances should be used only once to avoid shared mutable state.
*
* @author Mark Paluch
* @author Ge Jun
* @since 3.0
*/
public class ScanArgs implements CompositeArgument {
Expand Down Expand Up @@ -77,30 +76,28 @@ public static ScanArgs matches(String matches) {
}

/**
* Set the match filter.
* Set the match filter. Uses {@link StandardCharsets#UTF_8 UTF-8} to encode {@code match}.
*
* @param match the filter, must not be {@literal null}.
* @return {@literal this} {@link ScanArgs}.
*/
public ScanArgs match(String match) {

LettuceAssert.notNull(match, "Match must not be null");

this.match = match;
return this;
return match(match, StandardCharsets.UTF_8);
}

/**
* Set the match filter.
* Set the match filter along the given {@link Charset}.
*
* @param match the filter, must not be {@literal null}.
* @param charset the charset for match, must not be {@literal null}.
* @return {@literal this} {@link ScanArgs}.
* @since 5.3.1
*/
public ScanArgs match(String match, Charset charset) {

LettuceAssert.notNull(match, "Match must not be null");
LettuceAssert.notNull(charset, "Charset must not be null");

this.match = match;
this.charset = charset;
return this;
Expand All @@ -121,11 +118,7 @@ public ScanArgs limit(long count) {
public <K, V> void build(CommandArgs<K, V> args) {

if (match != null) {
if(charset==null) {
args.add(MATCH).add(match.getBytes(StandardCharsets.UTF_8));
} else {
args.add(MATCH).add(match.getBytes(charset));
}
args.add(MATCH).add(match.getBytes(charset));
}

if (count != null) {
Expand Down

0 comments on commit 4f9d330

Please sign in to comment.