CollectionHelper extends Helper<MorphixMongoConnector> { public String generate(Class<?> clazz) { Conditions.notNull(clazz); String name = clazz.getSimpleName(); if (snakeCase) { String[] parts = name.split(SNAKE_CASE_SPLIT_REGEX); StringBuilder builder = new StringBuilder(name.length() + (parts.length - 1)); for (int i = 0; i < parts.length - 1; i++) { builder.append(parts[i]).append('_'); } builder.append(parts[parts.length - 1]); name = builder.toString(); } if (lowerCase) { name = name.toLowerCase(); } return name; } CollectionHelper(MorphixMongoConnector connector); boolean isSnakeCase(); void setSnakeCase(boolean snakeCase); boolean isLowerCase(); void setLowerCase(boolean lowerCase); String generate(Class<?> clazz); String getCollection(Class<?> cls);  }
@Test void generate() { Class<CollectionHelper> cls = CollectionHelper.class; CollectionHelper helper = new CollectionHelper(null); helper.setSnakeCase(false); helper.setLowerCase(false); assertFalse(helper.isSnakeCase()); assertFalse(helper.isLowerCase()); assertEquals("CollectionHelper", helper.generate(cls)); helper.setLowerCase(true); assertTrue(helper.isLowerCase()); assertEquals("collectionhelper", helper.generate(cls)); helper.setSnakeCase(true); assertTrue(helper.isSnakeCase()); assertEquals("collection_helper", helper.generate(cls)); helper.setLowerCase(false); assertFalse(helper.isLowerCase()); assertEquals("Collection_Helper", helper.generate(cls)); }