Queue<Bean> beans = entry.getValue();
if (beans.isEmpty()) {
continue;
}
if (beans.size() > 1) {
throw new StLightException(ERROR_TOO_MANY_BEANS_OF_TYPE + type.getName());
}
if (response != null) {
throw new StLightException(ERROR_TOO_MANY_BEANS_OF_TYPE + type.getName());
}
response = (T) beans.peek().getBean();
}
}
// Check there is one
if (response == null) {
throw new StLightException(ERROR_NO_BEANS_OF_TYPE + type.getName());
}
return response;
}