/** * Resolves the {@link Class}[] of the {@code HandlesTypes}-annotations present on the given * {@code ServletContainerInitializer} implementation. * * @param servletContainerInitializerClassInfo The {@link ClassInfo} object representing the {@code ServletContainerInitializer} implementation * @return The classes listed in the {@code HandlesTypes} annotation of the given class. */ private List<ClassInfo> resolveHandledTypes(ClassInfo servletContainerInitializerClassInfo) { AnnotationInfo handlesTypes = servletContainerInitializerClassInfo.getAnnotationInfo(HANDLES_TYPES); Object[] value = (Object[]) handlesTypes.getParameterValues().get("value"); return Arrays.stream(value) .map(AnnotationClassRef.class::cast) .map(annotationClassRef -> { ClassInfo classInfo = annotationClassRef.getClassInfo(); if (classInfo == null) { log.warn("{} not found in the scan result, but declared in the @HandlesTypes annotation of {}", annotationClassRef.getName(), servletContainerInitializerClassInfo.getName()); } return classInfo; }) .filter(Objects::nonNull) .collect(Collectors.toList()); }
/** * Render as a string, into a StringBuilder buffer. * * @param buf * The buffer. */ void toString(final StringBuilder buf) { buf.append("@").append(getName()); if (annotationParamValues != null && !annotationParamValues.isEmpty()) { buf.append('('); for (int i = 0; i < annotationParamValues.size(); i++) { if (i > 0) { buf.append(", "); } final AnnotationParameterValue annotationParamValue = annotationParamValues.get(i); if (annotationParamValues.size() > 1 || !"value".equals(annotationParamValue.getName())) { annotationParamValue.toString(buf); } else { annotationParamValue.toStringParamValueOnly(buf); } } buf.append(')'); } }
@Override public int compareTo(final AnnotationInfo o) { final int diff = getName().compareTo(o.getName()); if (diff != 0) { return diff; } if (annotationParamValues == null && o.annotationParamValues == null) { return 0; } else if (annotationParamValues == null) { return -1; } else if (o.annotationParamValues == null) { return 1; } else { for (int i = 0, max = Math.max(annotationParamValues.size(), o.annotationParamValues.size()); i < max; i++) { if (i >= annotationParamValues.size()) { return -1; } else if (i >= o.annotationParamValues.size()) { return 1; } else { final int diff2 = annotationParamValues.get(i).compareTo(o.annotationParamValues.get(i)); if (diff2 != 0) { return diff2; } } } } return 0; }