/** * Construct an new descriptor by inspecting the supplied class. * * @param entityClass */ private EntityDescriptor(Class<?> entityClass) { // create a list of link headers this.linkHeaders = new ArrayList<>(); findLinkHeaders(entityClass); this.linkHeaders = Collections.unmodifiableList(linkHeaders); // create a list of field names this.nonLinkFields = new HashMap<>(); this.linkFields = new HashMap<>(); findFields(entityClass); this.nonLinkFields = Collections.unmodifiableMap(this.nonLinkFields); this.linkFields = Collections.unmodifiableMap(this.linkFields); }
private void findLinkHeaders(Class<?> entityClass) { InjectLink linkHeaderAnnotation = entityClass.getAnnotation(InjectLink.class); if (linkHeaderAnnotation != null) { linkHeaders.add(new LinkHeaderDescriptor(linkHeaderAnnotation)); } InjectLinks linkHeadersAnnotation = entityClass.getAnnotation(InjectLinks.class); if (linkHeadersAnnotation != null) { for (InjectLink linkHeader : linkHeadersAnnotation.value()) { linkHeaders.add(new LinkHeaderDescriptor(linkHeader)); } } // look in superclasses Class<?> sc = entityClass.getSuperclass(); if (sc != null && sc != Object.class) { findLinkHeaders(sc); } // look in interfaces for (Class<?> ic : entityClass.getInterfaces()) { findLinkHeaders(ic); } }