use of io.crnk.core.engine.parser.ParserException in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializer method deserializeFilter.
protected void deserializeFilter(QuerySpec querySpec, Parameter parameter) {
Class<?> attributeType = getAttributeType(querySpec, parameter.attributePath);
Set<Object> typedValues = new HashSet<>();
for (String stringValue : parameter.values) {
try {
@SuppressWarnings({ "unchecked", "rawtypes" }) Object value = typeParser.parse(stringValue, (Class) attributeType);
typedValues.add(value);
} catch (ParserException e) {
if (ignoreParseExceptions) {
typedValues.add(stringValue);
LOGGER.debug("failed to parse {}", parameter);
} else {
throw new ParametersDeserializationException(parameter.toString(), e);
}
}
}
Object value = typedValues.size() == 1 ? typedValues.iterator().next() : typedValues;
querySpec.addFilter(new FilterSpec(parameter.attributePath, parameter.operator, value));
}
Aggregations