io.vertx.codegen.format.SnakeCase Java Examples
The following examples show how to use
io.vertx.codegen.format.SnakeCase.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataObjectHelperGen.java From vertx-codegen with Apache License 2.0 | 6 votes |
private Case getCase(DataObjectModel model) { AnnotationValueInfo abc = model .getAnnotations() .stream().filter(ann -> ann.getName().equals(DataObject.class.getName())) .findFirst().get(); ClassTypeInfo cti = (ClassTypeInfo) abc.getMember("jsonPropertyNameFormatter"); switch (cti.getName()) { case "io.vertx.codegen.format.CamelCase": return CamelCase.INSTANCE; case "io.vertx.codegen.format.SnakeCase": return SnakeCase.INSTANCE; case "io.vertx.codegen.format.LowerCamelCase": return LowerCamelCase.INSTANCE; default: throw new UnsupportedOperationException("Todo"); } }
Example #2
Source File: TemplateExamples.java From vertx-sql-client with Apache License 2.0 | 5 votes |
public void customFormatter() { @DataObject @RowMapped(formatter = SnakeCase.class) @ParametersMapped(formatter = QualifiedCase.class) class UserDataObject { // ... } }
Example #3
Source File: MapperGenBase.java From vertx-sql-client with Apache License 2.0 | 5 votes |
private Case getCase(DataObjectModel model, String name) { AnnotationValueInfo abc = getAnnotation(model).get(); ClassTypeInfo cti = (ClassTypeInfo) abc.getMember(name); switch (cti.getName()) { case "io.vertx.codegen.format.CamelCase": return CamelCase.INSTANCE; case "io.vertx.codegen.format.SnakeCase": return SnakeCase.INSTANCE; case "io.vertx.codegen.format.LowerCamelCase": return LowerCamelCase.INSTANCE; default: throw new UnsupportedOperationException(); } }
Example #4
Source File: Lang.java From vertx-codetrans with Apache License 2.0 | 5 votes |
default File createSourceFile(File root, List<String> className, String methodName) { Stream.Builder<String> builder = Stream.builder(); className.forEach(builder::add); if (methodName != null) { builder.add((methodName)); } String t = builder .build() .map(s -> SnakeCase.INSTANCE.format(CamelCase.INSTANCE.parse(s)).replace('.', File.separatorChar)) .collect(Collectors.joining(File.separator)); return new File(root, t + "." + getExtension()); }
Example #5
Source File: CaseTest.java From vertx-codegen with Apache License 2.0 | 5 votes |
@Test public void testParseSnakeCase() { parseSnakeCase(""); parseSnakeCase("foo", "foo"); parseSnakeCase("foo_bar", "foo", "bar"); parseSnakeCase("foo_bar_juu", "foo", "bar", "juu"); for (String test : Arrays.asList("_", "_foo", "foo_", "foo__bar")) { try { SnakeCase.INSTANCE.parse(test); fail("Was expecting " + test + " to be rejected"); } catch (Exception ignore) { } } }
Example #6
Source File: CaseTest.java From vertx-codegen with Apache License 2.0 | 5 votes |
@Test public void testConversion() { assertEquals("foo-bar-juu", CamelCase.INSTANCE.to(KebabCase.INSTANCE, "FooBarJuu")); assertEquals("foo_bar_juu", CamelCase.INSTANCE.to(SnakeCase.INSTANCE, "FooBarJuu")); assertEquals("FooBarJuu", SnakeCase.INSTANCE.to(CamelCase.INSTANCE, "foo_bar_juu")); assertEquals("FooBarJuu", KebabCase.INSTANCE.to(CamelCase.INSTANCE, "foo-bar-juu")); }
Example #7
Source File: CaseTest.java From vertx-codegen with Apache License 2.0 | 4 votes |
private void formatSnakeCase(String expected, String... atoms) { assertCase(SnakeCase.INSTANCE, expected, atoms); }
Example #8
Source File: CaseTest.java From vertx-codegen with Apache License 2.0 | 4 votes |
private void parseSnakeCase(String s, String... expected) { parseCase(SnakeCase.INSTANCE, s, expected); }