(Element element)
| 43 | } |
| 44 | |
| 45 | ValidationReport<Element> validate(Element element) { |
| 46 | ValidationReport.Builder<Element> builder = ValidationReport.about(element); |
| 47 | List<ExecutableElement> members = methodsIn(((TypeElement) element).getEnclosedElements()); |
| 48 | if (members.isEmpty()) { |
| 49 | builder.addError(MAPKEY_WITHOUT_MEMBERS, element); |
| 50 | } else if (element.getAnnotation(MapKey.class).unwrapValue()) { |
| 51 | if (members.size() > 1) { |
| 52 | builder.addError(UNWRAPPED_MAP_KEY_WITH_TOO_MANY_MEMBERS, element); |
| 53 | } else if (members.get(0).getReturnType().getKind() == TypeKind.ARRAY) { |
| 54 | builder.addError(UNWRAPPED_MAP_KEY_WITH_ARRAY_MEMBER, element); |
| 55 | } |
| 56 | } else if (autoAnnotationIsMissing()) { |
| 57 | builder.addError( |
| 58 | "@AutoAnnotation is a necessary dependency if @MapKey(unwrapValue = false). Add a " |
| 59 | + "dependency on com.google.auto.value:auto-value:<current version>"); |
| 60 | } |
| 61 | return builder.build(); |
| 62 | } |
| 63 | |
| 64 | private boolean autoAnnotationIsMissing() { |
| 65 | return elements.getTypeElement("com.google.auto.value.AutoAnnotation") == null; |
nothing calls this directly
no test coverage detected