implements KijiRowFilterDeserializer {
/** {@inheritDoc} */
@Override
public KijiRowFilter createFromJson(JsonNode root) {
try {
final RowKeyFormat2 rowKeyFormat = (RowKeyFormat2) FromJson.fromAvroJsonString(
root.path(ROW_KEY_FORMAT_NODE).getTextValue(), RowKeyFormat2.SCHEMA$);
final JsonNode componentsJsonNode = root.path(COMPONENTS_NODE);
Preconditions.checkArgument(componentsJsonNode.isArray(),
"Node 'components' must be an array");
final ArrayNode componentsNode = (ArrayNode)componentsJsonNode;
final Object[] components = new Object[componentsNode.size()];
for (int i = 0; i < components.length; i++) {
JsonNode componentNode = componentsNode.get(i);
if (componentNode.isNull()) {
components[i] = null; // an explicit no-op
} else {
switch (rowKeyFormat.getComponents().get(i).getType()) {
case INTEGER:
components[i] = Integer.valueOf(componentNode.getIntValue());
break;
case LONG:
components[i] = Long.valueOf(componentNode.getLongValue());
break;
case STRING:
components[i] = componentNode.getTextValue();
break;
default:
throw new IllegalStateException("Unknown component type: "
+ rowKeyFormat.getComponents().get(i).getType());
}
}
}
return new FormattedEntityIdRowFilter(rowKeyFormat, components);
} catch (IOException ioe) {