-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
18 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,31 +47,31 @@ | |
* @author Stephan Saalfeld <[email protected]> | ||
* @author Michael Innerberger | ||
*/ | ||
public enum Filter { | ||
// Note: the JSON (de-)serializer below is very much tailored to this filter, which serializes to "{"id":"vlen-utf8"}" | ||
// If additional filters are implemented, consider also changing the type adapter below | ||
VLEN_UTF8("vlen-utf8"); | ||
public interface Filter { | ||
|
||
private final String id; | ||
String getId(); | ||
|
||
Filter(final String id) { | ||
this.id = id; | ||
} | ||
// Note: the JSON (de-)serializer below is very much tailored to this filter, which serializes to "{"id":"vlen-utf8"}" | ||
// If additional filters are implemented, consider also changing the type adapter below | ||
Filter VLEN_UTF8 = new VLenStringFilter(); | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
class VLenStringFilter implements Filter { | ||
private static final String id = "vlen-utf8"; | ||
@Override | ||
public String getId() { | ||
return id; | ||
} | ||
}; | ||
|
||
public static Filter fromString(final String id) { | ||
for (final Filter filter : values()) | ||
if (filter.getId().equals(id)) | ||
return filter; | ||
static Filter fromString(final String id) { | ||
if (VLEN_UTF8.getId().equals(id)) | ||
return VLEN_UTF8; | ||
return null; | ||
} | ||
|
||
public static final JsonAdapter jsonAdapter = new JsonAdapter(); | ||
JsonAdapter jsonAdapter = new JsonAdapter(); | ||
|
||
public static class JsonAdapter implements JsonDeserializer<Filter>, JsonSerializer<Filter> { | ||
class JsonAdapter implements JsonDeserializer<Filter>, JsonSerializer<Filter> { | ||
|
||
@Override | ||
public Filter deserialize( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters