AnnotatedServiceFactory { @Nullable static String findDescription(AnnotatedElement annotatedElement) { requireNonNull(annotatedElement, "annotatedElement"); final Description description = AnnotationUtil.findFirst(annotatedElement, Description.class); if (description != null) { final String value = description.value(); if (DefaultValues.isSpecified(value)) { checkArgument(!value.isEmpty(), "value is empty."); return value; } } else if (annotatedElement instanceof Parameter) { final Parameter parameter = (Parameter) annotatedElement; final Executable executable = parameter.getDeclaringExecutable(); final Class<?> clazz = executable.getDeclaringClass(); final String fileName = getFileName(clazz.getCanonicalName()); final String propertyName = executable.getName() + '.' + parameter.getName(); final Properties cachedProperties = DOCUMENTATION_PROPERTIES_CACHE.getIfPresent(fileName); if (cachedProperties != null) { return cachedProperties.getProperty(propertyName); } try (InputStream stream = AnnotatedServiceFactory.class.getClassLoader() .getResourceAsStream(fileName)) { if (stream == null) { return null; } final Properties properties = new Properties(); properties.load(stream); DOCUMENTATION_PROPERTIES_CACHE.put(fileName, properties); return properties.getProperty(propertyName); } catch (IOException exception) { logger.warn("Failed to load an API description file: {}", fileName, exception); } } return null; } private  AnnotatedServiceFactory(); static List<AnnotatedServiceElement> find(
            String pathPrefix, Object object, boolean useBlockingTaskExecutor,
            List<RequestConverterFunction> requestConverterFunctions,
            List<ResponseConverterFunction> responseConverterFunctions,
            List<ExceptionHandlerFunction> exceptionHandlerFunctions);  }
@Test void testDescriptionLoadingPriority() throws NoSuchMethodException { final Parameter parameter = DescriptionAnnotatedTestClass.class.getMethod("testMethod1", String.class) .getParameters()[0]; assertThat(AnnotatedServiceFactory.findDescription(parameter)).isEqualTo(ANNOTATED_DESCRIPTION); }
@Test void testDescriptionLoadFromFile() throws NoSuchMethodException { final Parameter parameter = DescriptionAnnotatedTestClass.class.getMethod("testMethod2", String.class) .getParameters()[0]; assertThat(AnnotatedServiceFactory.findDescription(parameter)) .isEqualTo("This is a description from the properties file"); }