class DefaultTypeDeterminator implements TypeDeterminator {

    @SuppressWarnings("unchecked")
    @Override
    public <T> Class<T> determineClass(Class<T> type, Class<? extends T>[] candidates, Annotation qualifier, ClassLoader classLoader) {
        String namePrefix = "";
        
        if (qualifier != null) {
            if (qualifier instanceof Named) {
                namePrefix = ((Named) qualifier).value();
            } else {
                namePrefix = qualifier.annotationType().getSimpleName();
            }
            
            if (candidates != null) {
                for (Class<? extends T> candidate : candidates) {
                    if (candidate.getSimpleName().toLowerCase().startsWith(namePrefix.toLowerCase())) {
                        LOGGER.debug("determineClass - returning decent {} for {}", candidate, type);
                        return (Class<T>) candidate;
                    }
                }
            }
        }
        
        LOGGER.debug("determineClass - returning {} for {}", type, type);
        return type;
    }

}