use of org.apache.camel.impl.transformer.TransformerKey in project camel by apache.
the class DefaultTransformerRegistry method resolveTransformer.
@Override
public Transformer resolveTransformer(TransformerKey key) {
if (ObjectHelper.isEmpty(key.getScheme()) && key.getTo() == null) {
return null;
}
// try exact match
Transformer answer = get(aliasMap.containsKey(key) ? aliasMap.get(key) : key);
if (answer != null || ObjectHelper.isNotEmpty(key.getScheme())) {
return answer;
}
// try wildcard match for next - add an alias if matched
TransformerKey alias = null;
if (key.getFrom() != null && ObjectHelper.isNotEmpty(key.getFrom().getName())) {
alias = new TransformerKey(new DataType(key.getFrom().getModel()), key.getTo());
answer = get(alias);
}
if (answer == null && ObjectHelper.isNotEmpty(key.getTo().getName())) {
alias = new TransformerKey(key.getFrom(), new DataType(key.getTo().getModel()));
answer = get(alias);
}
if (answer == null && key.getFrom() != null && ObjectHelper.isNotEmpty(key.getFrom().getName()) && ObjectHelper.isNotEmpty(key.getTo().getName())) {
alias = new TransformerKey(new DataType(key.getFrom().getModel()), new DataType(key.getTo().getModel()));
answer = get(alias);
}
if (answer == null && key.getFrom() != null) {
alias = new TransformerKey(key.getFrom().getModel());
answer = get(alias);
}
if (answer == null) {
alias = new TransformerKey(key.getTo().getModel());
answer = get(alias);
}
if (answer != null) {
aliasMap.put(key, alias);
}
return answer;
}
Aggregations