@Override public Map<String, String> attributes() { if (attributes != null) { return attributes; } attributes = new HashMap<>(); T annotation = getItem(); if (annotation != null) { if (annotation instanceof Structure) { addAttribute(attributes, "class", ((Structure) annotation).getElementClass()); addAttribute(attributes, "id", ((Structure) annotation).getElementId()); } for (Method method : annotation.getClass().getDeclaredMethods()) { String name = method.getName(); if (name.startsWith("get") && method.getParameterTypes().length == 0 && !nonAttributes.contains(name)) { String key = name.substring(3).toLowerCase(); try { addAttribute(attributes, key, method.invoke(annotation)); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e); } } } } return attributes; }
@Override public Map<String, String> attributes() { if (attributes != null) { return attributes; } attributes = new HashMap<>(); T annotation = getItem(); if (annotation != null) { if (annotation instanceof Structure) { addAttribute(attributes, "class", ((Structure) annotation).getElementClass()); addAttribute(attributes, "id", ((Structure) annotation).getElementId()); } for (Method method : annotation.getClass().getDeclaredMethods()) { String name = method.getName(); if (name.startsWith("get") && method.getParameterTypes().length == 0 && !nonAttributes.contains(name)) { String key = name.substring(3).toLowerCase(); try { addAttribute(attributes, key, method.invoke(annotation)); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e); } } } } return attributes; }