@@ -31,14 +31,16 @@ public class ScanOptions {
31
31
/**
32
32
* Constant to apply default {@link ScanOptions} without setting a limit or matching a pattern.
33
33
*/
34
- public static ScanOptions NONE = new ScanOptions (null , null );
34
+ public static ScanOptions NONE = new ScanOptions (null , null , null );
35
35
36
36
private final @ Nullable Long count ;
37
37
private final @ Nullable String pattern ;
38
+ private final @ Nullable byte [] bytePattern ;
38
39
39
- private ScanOptions (@ Nullable Long count , @ Nullable String pattern ) {
40
+ private ScanOptions (@ Nullable Long count , @ Nullable String pattern , @ Nullable byte [] bytePattern ) {
40
41
this .count = count ;
41
42
this .pattern = pattern ;
43
+ this .bytePattern = bytePattern ;
42
44
}
43
45
44
46
/**
@@ -57,9 +59,24 @@ public Long getCount() {
57
59
58
60
@ Nullable
59
61
public String getPattern () {
62
+
63
+ if (bytePattern != null && pattern == null ) {
64
+ return new String (bytePattern );
65
+ }
66
+
60
67
return pattern ;
61
68
}
62
69
70
+ @ Nullable
71
+ public byte [] getBytePattern () {
72
+
73
+ if (bytePattern == null && pattern != null ) {
74
+ return pattern .getBytes ();
75
+ }
76
+
77
+ return bytePattern ;
78
+ }
79
+
63
80
public String toOptionString () {
64
81
65
82
if (this .equals (ScanOptions .NONE )) {
@@ -71,7 +88,8 @@ public String toOptionString() {
71
88
if (this .count != null ) {
72
89
params += (", 'count', " + count );
73
90
}
74
- if (StringUtils .hasText (this .pattern )) {
91
+ String pattern = getPattern ();
92
+ if (StringUtils .hasText (pattern )) {
75
93
params += (", 'match' , '" + this .pattern + "'" );
76
94
}
77
95
@@ -87,6 +105,7 @@ public static class ScanOptionsBuilder {
87
105
88
106
private @ Nullable Long count ;
89
107
private @ Nullable String pattern ;
108
+ private @ Nullable byte [] bytePattern ;
90
109
91
110
92
111
/**
@@ -111,13 +130,25 @@ public ScanOptionsBuilder match(String pattern) {
111
130
return this ;
112
131
}
113
132
133
+ /**
134
+ * Returns the current {@link ScanOptionsBuilder} configured with the given {@code pattern}.
135
+ *
136
+ * @param pattern
137
+ * @return
138
+ * @since 2.6
139
+ */
140
+ public ScanOptionsBuilder match (byte [] pattern ) {
141
+ this .bytePattern = pattern ;
142
+ return this ;
143
+ }
144
+
114
145
/**
115
146
* Builds a new {@link ScanOptions} objects.
116
147
*
117
148
* @return a new {@link ScanOptions} objects.
118
149
*/
119
150
public ScanOptions build () {
120
- return new ScanOptions (count , pattern );
151
+ return new ScanOptions (count , pattern , bytePattern );
121
152
}
122
153
}
123
154
}
0 commit comments