@Override public String id() { T annotation = getItem(); if (annotation instanceof Structure) { String id = ((Structure) annotation).getElementId(); if (id != null) { return id; } } return ""; }
@Override public String id() { T annotation = getItem(); if (annotation instanceof Structure) { String id = ((Structure) annotation).getElementId(); if (id != null) { return id; } } return ""; }
@Override public List<String> getClasses() { T annotation = getItem(); if (annotation instanceof Structure) { String classes = ((Structure) annotation).getElementClass(); if (StringUtils.isNotBlank(classes)) { return Arrays.asList(classes.split("\\s")) .stream() .map(String::toLowerCase) .collect(Collectors.toList()); } } return ImmutableList.of(); }
@Override public List<String> getClasses() { T annotation = getItem(); if (annotation instanceof Structure) { String classes = ((Structure) annotation).getElementClass(); if (StringUtils.isNotBlank(classes)) { return Arrays.asList(classes.split("\\s")) .stream() .map(String::toLowerCase) .collect(Collectors.toList()); } } return ImmutableList.of(); }
@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; }
private static <T extends Annotation> boolean testNodePassed(AnnotationNode<T> node, T s) { int begin = s.getBegin(); int end = AnnotationNode.getEnd(node); return end < begin || end == begin && getDepth(node.getItem()) >= getDepth(s); } }
private static <T extends Annotation> boolean testNodePassed(AnnotationNode<T> node, T s) { int begin = s.getBegin(); int end = AnnotationNode.getEnd(node); return end < begin || end == begin && getDepth(node.getItem()) >= getDepth(s); } }