{
if (logger.isDebugEnabled())
{
logger.debug("Comparing transformers for best match: input = " + input + " output = " + output + " Possible transformers = " + trans);
}
TransformerWeighting weighting = null;
for (Transformer transformer : trans)
{
TransformerWeighting current = new TransformerWeighting(input, output, transformer);
if (weighting == null)
{
weighting = current;
}
else
{
int compare = current.compareTo(weighting);
if (compare == 1)
{
weighting = current;
}
else if (compare == 0)
{
//We may have two transformers that are exactly the same, in which case we can use either i.e. use the current
if (!weighting.getTransformer().getClass().equals(current.getTransformer().getClass()))
{
throw new ResolverException(CoreMessages.transformHasMultipleMatches(input, output,
current.getTransformer(), weighting.getTransformer()));
}
}
}
}
return weighting.getTransformer();