EntityDataModelUtil { public static String pluralize(String word) { if (word == null) { throw new IllegalArgumentException(); } final String lowerCaseWord = word.toLowerCase(); if (endsWithAny(lowerCaseWord, "s", "sh", "o")) { return word + "es"; } if (lowerCaseWord.endsWith("y") && !lowerCaseWord.endsWith("ay") || endsWithAny(lowerCaseWord, "ey", "oy", "uy")) { return word.substring(0, word.length() - 1) + "ies"; } else { return word + "s"; } } private  EntityDataModelUtil(); static Type getAndCheckType(EntityDataModel entityDataModel, String typeName); static Type getAndCheckType(EntityDataModel entityDataModel, Class<?> javaType); static boolean isPrimitiveType(Type type); static PrimitiveType checkIsPrimitiveType(Type type); static PrimitiveType getAndCheckPrimitiveType(EntityDataModel entityDataModel, String typeName); static boolean isStructuredType(Type type); static StructuredType checkIsStructuredType(Type type); static StructuredType getAndCheckStructuredType(EntityDataModel entityDataModel, String typeName); static StructuredType getAndCheckStructuredType(EntityDataModel entityDataModel, Class<?> javaType); static boolean isEntityType(Type type); static EntityType checkIsEntityType(Type type); static EntityType getAndCheckEntityType(EntityDataModel entityDataModel, String typeName); static EntityType getAndCheckEntityType(EntityDataModel entityDataModel, Class<?> javaType); static boolean isComplexType(Type type); static ComplexType checkIsComplexType(Type type); static ComplexType getAndCheckComplexType(EntityDataModel entityDataModel, Class<?> javaType); static String getPropertyTypeName(StructuralProperty property); static Type getPropertyType(EntityDataModel entityDataModel, StructuralProperty property); static Object getPropertyValue(StructuralProperty property, Object object); static void setPropertyValue(StructuralProperty property, Object object, Object value); static Collection<Object> createPropertyCollection(StructuralProperty property); static void visitProperties(EntityDataModel entityDataModel,
                                                                  StructuredType structType, PropertyVisitor<E> visitor); static StructuralProperty getStructuralProperty(EntityDataModel entityDataModel,
                                                           StructuredType structuredType, String propertyName); static Set<String> getKeyPropertyNames(EntityType entityType); static Map<String, Object> getKeyPropertyValues(EntityType entityType, Object entity); static EntitySet getAndCheckEntitySet(EntityDataModel entityDataModel, String entitySetName); static EntitySet getEntitySetByEntityTypeName(EntityDataModel entityDataModel, String entityTypeName); static String getEntityNameByEntityTypeName(EntityDataModel entityDataModel, String entityTypeName); static EntitySet getEntitySetByEntity(EntityDataModel entityDataModel, Object entity); static boolean isSingletonEntity(EntityDataModel entityDataModel, Object entity); static String getEntityName(EntityDataModel entityDataModel, Object entity); static Singleton getAndCheckSingleton(EntityDataModel entityDataModel, String singletonName); static FunctionImport getAndCheckFunctionImport(EntityDataModel entityDataModel, String functionImportName); static Function getAndCheckFunction(EntityDataModel entityDataModel, String functionName); static ActionImport getAndCheckActionImport(EntityDataModel entityDataModel, String actionImportName); static Action getAndCheckAction(EntityDataModel entityDataModel, String actionName); static boolean isCollection(EntityDataModel entityDataModel, String typeName); static String formatEntityKey(EntityDataModel entityDataModel, Object entity); static String pluralize(String word); static final Pattern COLLECTION_PATTERN; }
@Test public void testPluralize() throws Exception { assertThat(pluralize("Bus"), is("Buses")); assertThat(pluralize("Hash"), is("Hashes")); assertThat(pluralize("Potato"), is("Potatoes")); assertThat(pluralize("Capability"), is("Capabilities")); assertThat(pluralize("Day"), is("Days")); assertThat(pluralize("WebApplication"), is("WebApplications")); }
@Test(expected = IllegalArgumentException.class) public void testPluralizeNull() throws Exception { pluralize(null); }