Java源码示例:io.vertx.codegen.format.Case

示例1
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");
  }
}
 
示例2
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();
  }
}
 
示例3
public String getName(Case _case) {
  return _case.format(CamelCase.INSTANCE.parse(name));
}
 
示例4
public String getName(Case _case) {
  return _case.format(CamelCase.INSTANCE.parse(name));
}
 
示例5
public String getSimpleName(Case _case) {
  return _case.format(CamelCase.INSTANCE.parse(simpleName));
}
 
示例6
private void assertCase(Case _case, String expected, String... atoms) {
  assertEquals(expected, _case.format(Arrays.asList(atoms)));
}
 
示例7
private void parseCase(Case _case, String s, String... expected) {
  assertEquals(Arrays.asList(expected), _case.parse(s));
}
 
示例8
/**
 * @param _case the formatting case
 * @return the module name in the specified case
 */
public String getName(Case _case) {
  return _case.format(KebabCase.INSTANCE.parse(name));
}