class RestExceptionHandlerRegistry {

    public Optional<ExceptionHandlerBinding> findBindingFor(Class<? extends Throwable> exceptionClass) {
        if (exceptionHandlerBindings == null || exceptionHandlerBindings.isEmpty()) {
            return Optional.empty();
        }
        int currentDistance = Integer.MAX_VALUE;
        ExceptionHandlerBinding closestBinding = null;
        for (ExceptionHandlerBinding binding : exceptionHandlerBindings) {
            int tempDistance = getDistanceBetweenExceptions(exceptionClass, binding.getExceptionClass());
            if (tempDistance < currentDistance) {
                currentDistance = tempDistance;
                closestBinding = binding;
                if (currentDistance == 0) {
                    break;
                }
            }
        }
        return Optional.ofNullable(closestBinding);
    }

    public  RestExceptionHandlerRegistry(Set<ExceptionHandlerBinding> bindings);

}