@Test public void testGenerateDescriptionsForField() throws NoSuchFieldException { String FIELD_NAME = "someField"; String DESCRIPTION_FROM_FIELD_NAME = "some field"; Field field = Dummy.class.getDeclaredField(FIELD_NAME); List<String> sortedDescriptions; sortedDescriptions = NliDescriptionsUtils.generateDescriptionsForRelationField(field, false).stream().sorted() .collect(Collectors.toList()); assertEquals(sortedDescriptions, Stream.of(DESCRIPTION_FROM_FIELD_NAME).sorted().collect(Collectors.toList())); sortedDescriptions = NliDescriptionsUtils.generateDescriptionsForRelationField(field, true).stream().sorted() .collect(Collectors.toList()); assertEquals(sortedDescriptions, Stream.of("b", "hello again",DESCRIPTION_FROM_FIELD_NAME).sorted() .collect(Collectors.toList())); }
public static List<String> generateDescriptionsForRelationField(Field relationField, boolean useAnnotation) { List<String> result = new ArrayList<>(); result.add(createDescriptionFromIdentifierName(relationField.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = relationField.getAnnotation(NliDescriptions.class); if (descriptionAnnotation != null) result.addAll(generateDescriptionsFromAnnotation(descriptionAnnotation)); } return result; }
NliDescriptionsUtils { public static List<String> generateDescriptionsForRelationField(Field relationField, boolean useAnnotation) { List<String> result = new ArrayList<>(); result.add(createDescriptionFromIdentifierName(relationField.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = relationField.getAnnotation(NliDescriptions.class); if (descriptionAnnotation != null) result.addAll(generateDescriptionsFromAnnotation(descriptionAnnotation)); } return result; } }
NliDescriptionsUtils { public static List<String> generateDescriptionsForRelationField(Field relationField, boolean useAnnotation) { List<String> result = new ArrayList<>(); result.add(createDescriptionFromIdentifierName(relationField.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = relationField.getAnnotation(NliDescriptions.class); if (descriptionAnnotation != null) result.addAll(generateDescriptionsFromAnnotation(descriptionAnnotation)); } return result; }  }
NliDescriptionsUtils { public static List<String> generateDescriptionsForRelationField(Field relationField, boolean useAnnotation) { List<String> result = new ArrayList<>(); result.add(createDescriptionFromIdentifierName(relationField.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = relationField.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> generateDescriptionsForRelationField(Field relationField, boolean useAnnotation) { List<String> result = new ArrayList<>(); result.add(createDescriptionFromIdentifierName(relationField.getName())); if (useAnnotation) { NliDescriptions descriptionAnnotation = relationField.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);  }