/** * Creates a {@link ResourceDocument} by given data attributes with its type and id. * * @param <T> the type of attributes * @param attributes the data object * @param type the type of data * @param id the id of data * @return a {@link ResourceDocument} */ public static <T> ResourceDocument<T> resourceDocument(T attributes, String type, String id) { ResourceDocument<T> document = new ResourceDocument<T>(); ResourceObject<T> resource = resource(attributes, type); if (id != null) resource.setId(id); document.setData(resource); return document; }
@Override protected void doWithResourceDocument(ResourceDocument document, Class<?> classOfResource) { // Check if the class is present in the builder. if (javaDocBuilder.getClassByName(classOfResource.getName()) == null) throw new IllegalArgumentException( "Class " + classOfResource + " was not found within the specified source files."); JavaClass javaClass = javaDocBuilder.getClassByName(classOfResource.getName()); document.setDescription(javaClass.getComment()); document.setTitle(titleOrNull(javaClass)); }
@Override protected void doWithResourceDocument(ResourceDocument document, Class<?> classOfResource) { LOG.info("Generating ResourceDocument for {}", classOfResource); if (!classOfResource.isAnnotationPresent(ResourceDoc.class)) { throw new RuntimeException( "Cannot generate documentation for a resource class " + "that is not annotated with @ResoureceDoc"); } // --- Process TGIRest annotations ResourceDoc rd = (ResourceDoc) classOfResource.getAnnotation(ResourceDoc.class); document.setDescription(rd.description()); document.setTitle(rd.title()); }