Exemplo n.º 1
0
 @Nullable
 public static DomNameStrategy getDomNameStrategy(final Class<?> rawType, boolean isAttribute) {
   Class aClass = null;
   if (isAttribute) {
     NameStrategyForAttributes annotation =
         DomReflectionUtil.findAnnotationDFS(rawType, NameStrategyForAttributes.class);
     if (annotation != null) {
       aClass = annotation.value();
     }
   }
   if (aClass == null) {
     NameStrategy annotation = DomReflectionUtil.findAnnotationDFS(rawType, NameStrategy.class);
     if (annotation != null) {
       aClass = annotation.value();
     }
   }
   if (aClass != null) {
     if (HyphenNameStrategy.class.equals(aClass)) return DomNameStrategy.HYPHEN_STRATEGY;
     if (JavaNameStrategy.class.equals(aClass)) return DomNameStrategy.JAVA_STRATEGY;
     try {
       return (DomNameStrategy) aClass.newInstance();
     } catch (InstantiationException e) {
       LOG.error(e);
     } catch (IllegalAccessException e) {
       LOG.error(e);
     }
   }
   return null;
 }