eu.xenit.apix.search.json.OperatorSearchNodeDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apix-interface Show documentation
Show all versions of apix-interface Show documentation
Xenit API-X Java interface
package eu.xenit.apix.search.json;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import eu.xenit.apix.search.nodes.OperatorSearchNode;
import eu.xenit.apix.search.nodes.SearchSyntaxNode;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Michiel Huygen on 10/11/2015.
*/
public class OperatorSearchNodeDeserializer extends JsonDeserializer {
@Override
public OperatorSearchNode deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
// Anti-hack for the 'hack' in AsWrapperType, remove 'nodeType' field again
if (jp.getCurrentToken() != JsonToken.START_ARRAY) {
throw new UnsupportedOperationException();
}
List nodes = new ArrayList<>();
while (jp.nextToken() != JsonToken.END_ARRAY) {
// We are in an array element
SearchSyntaxNode nested = (SearchSyntaxNode) ctxt
.findRootValueDeserializer(ctxt.constructType(SearchSyntaxNode.class)).deserialize(jp, ctxt);
nodes.add(nested);
}
// Type is set using the IJsonTyped interface
return new OperatorSearchNode(null, nodes);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy