use of com.linkedin.restli.client.config.RequestConfigKeyParser.KeyContext in project parseq by linkedin.
the class RequestConfigElement method parse.
static RequestConfigElement parse(String property, String key, Object value) throws RequestConfigKeyParsingException {
RequestConfigKeyParsingErrorListener errorListener = new RequestConfigKeyParsingErrorListener();
ANTLRInputStream input = new ANTLRInputStream(key);
RequestConfigKeyLexer lexer = new RequestConfigKeyLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
CommonTokenStream tokens = new CommonTokenStream(lexer);
RequestConfigKeyParser parser = new RequestConfigKeyParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
KeyContext keyTree = parser.key();
if (!errorListener.hasErrors()) {
InboundContext inbound = keyTree.inbound();
OutboundContext outbound = keyTree.outbound();
Optional<String> inboundName = handlingWildcard(inbound.restResource());
Optional<String> outboundName = handlingWildcard(outbound.restResource());
Optional<String> inboundOp = getOpIn(inbound.operationIn());
Optional<ResourceMethod> outboundOp = getOpOut(outbound.operationOut());
Optional<String> inboundOpName = inboundOp.flatMap(method -> getOpInName(method, inbound.operationIn()));
Optional<String> outboundOpName = outboundOp.flatMap(method -> getOpOutName(method, outbound.operationOut()));
return new RequestConfigElement(key, coerceValue(property, value), property, inboundName, outboundName, inboundOpName, outboundOpName, inboundOp, outboundOp);
} else {
throw new RequestConfigKeyParsingException("Error" + ((errorListener.errorsSize() > 1) ? "s" : "") + " parsing key: " + key + "\n" + errorListener);
}
}
Aggregations