@Test public void testGenerateDescriptionsForMethod() throws NoSuchMethodException { String METHOD_NAME = "someMethod"; String DESCRIPTION_FROM_METHOD_NAME = "some method"; Method method = Dummy.class.getDeclaredMethod(METHOD_NAME); List<String> sortedDescriptions; sortedDescriptions = NliDescriptionsUtils.generateDescriptionsForMethod(method, false).stream().sorted() .collect(Collectors.toList()); assertEquals(sortedDescriptions, Stream.of(DESCRIPTION_FROM_METHOD_NAME).sorted().collect(Collectors.toList())); sortedDescriptions = NliDescriptionsUtils.generateDescriptionsForMethod(method, true).stream().sorted() .collect(Collectors.toList()); assertEquals(sortedDescriptions, Stream.of("a", "hello world",DESCRIPTION_FROM_METHOD_NAME).sorted() .collect(Collectors.toList())); }
public static List<String> generateDescriptionsForMethod(Method nliMethod, boolean useAnnotation) { List<String> result = new ArrayList<>(); assert (NliMethodReflection.isValidNliMethod(nliMethod)); result.add(createDescriptionFromIdentifierName(nliMethod.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = nliMethod.getAnnotation(NliDescriptions.class); if (descriptionAnnotation != null) result.addAll(generateDescriptionsFromAnnotation(descriptionAnnotation)); } return result; }
NliDescriptionsUtils { public static List<String> generateDescriptionsForMethod(Method nliMethod, boolean useAnnotation) { List<String> result = new ArrayList<>(); assert (NliMethodReflection.isValidNliMethod(nliMethod)); result.add(createDescriptionFromIdentifierName(nliMethod.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = nliMethod.getAnnotation(NliDescriptions.class); if (descriptionAnnotation != null) result.addAll(generateDescriptionsFromAnnotation(descriptionAnnotation)); } return result; } }
NliDescriptionsUtils { public static List<String> generateDescriptionsForMethod(Method nliMethod, boolean useAnnotation) { List<String> result = new ArrayList<>(); assert (NliMethodReflection.isValidNliMethod(nliMethod)); result.add(createDescriptionFromIdentifierName(nliMethod.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = nliMethod.getAnnotation(NliDescriptions.class); if (descriptionAnnotation != null) result.addAll(generateDescriptionsFromAnnotation(descriptionAnnotation)); } return result; }  }
NliDescriptionsUtils { public static List<String> generateDescriptionsForMethod(Method nliMethod, boolean useAnnotation) { List<String> result = new ArrayList<>(); assert (NliMethodReflection.isValidNliMethod(nliMethod)); result.add(createDescriptionFromIdentifierName(nliMethod.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = nliMethod.getAnnotation(NliDescriptions.class); if (descriptionAnnotation != null) result.addAll(generateDescriptionsFromAnnotation(descriptionAnnotation)); } return result; }  static List<String> generateDescriptionsForMethod(Method nliMethod, boolean useAnnotation); static List<String> generateDescriptionsForRelationField(Field relationField, boolean useAnnotation); static List<String> generateDescriptionsForNliEntityType(Class<? extends NliEntity> entityType,
                                                                    boolean useAnnotation); static List<String> generateDescriptionsForEnumType(Class<Enum<?>> enumType,
                                                               boolean useAnnotation); static List<String> generateDescriptionsForEnumValue(Enum<?> enumValue); }
NliDescriptionsUtils { public static List<String> generateDescriptionsForMethod(Method nliMethod, boolean useAnnotation) { List<String> result = new ArrayList<>(); assert (NliMethodReflection.isValidNliMethod(nliMethod)); result.add(createDescriptionFromIdentifierName(nliMethod.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = nliMethod.getAnnotation(NliDescriptions.class); if (descriptionAnnotation != null) result.addAll(generateDescriptionsFromAnnotation(descriptionAnnotation)); } return result; }  static List<String> generateDescriptionsForMethod(Method nliMethod, boolean useAnnotation); static List<String> generateDescriptionsForRelationField(Field relationField, boolean useAnnotation); static List<String> generateDescriptionsForNliEntityType(Class<? extends NliEntity> entityType,
                                                                    boolean useAnnotation); static List<String> generateDescriptionsForEnumType(Class<Enum<?>> enumType,
                                                               boolean useAnnotation); static List<String> generateDescriptionsForEnumValue(Enum<?> enumValue);  }