Commit 682742c1 authored by Maxym Borodenko's avatar Maxym Borodenko

Added helper methods to StringFilter

parent 72fb1734
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.genesys.blocks.model.filters; package org.genesys.blocks.model.filters;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
...@@ -67,17 +68,64 @@ public class StringFilter { ...@@ -67,17 +68,64 @@ public class StringFilter {
} }
/** /**
* Eq. * Equals.
* *
* @param val the val * @param val the val
* @return the string filter * @return the string filter
*
* @deprecated Use {@link #eq(String[])}
*/ */
public static StringFilter eq(final String... val) { public static StringFilter equals(final String... val) {
final StringFilter filter = new StringFilter(); final StringFilter filter = new StringFilter();
filter.eq = Sets.newHashSet(val); filter.eq = Sets.newHashSet(val);
return filter; return filter;
} }
/**
* Eq.
*
* @param val the val
* @return the string filter
*/
public StringFilter eq(final String... val) {
if (eq != null && !eq.isEmpty()) {
eq.addAll(Arrays.asList(val));
} else {
eq = Sets.newHashSet(val);
}
return this;
}
/**
* Contains.
*
* @param val the val
* @return the string filter
*/
public StringFilter contains(final String... val) {
if (contains != null && !contains.isEmpty()) {
contains.addAll(Arrays.asList(val));
} else {
contains = Sets.newHashSet(val);
}
return this;
}
/**
* Sw.
*
* @param val the val
* @return the string filter
*/
public StringFilter sw(final String... val) {
if (sw != null && !sw.isEmpty()) {
sw.addAll(Arrays.asList(val));
} else {
sw = Sets.newHashSet(val);
}
return this;
}
static class SetDeserializer extends JsonDeserializer<Set<String>> { static class SetDeserializer extends JsonDeserializer<Set<String>> {
@Override @Override
public Set<String> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { public Set<String> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment