io.vertx.codegen.annotations.DataObject Java Examples
The following examples show how to use
io.vertx.codegen.annotations.DataObject.
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: GeneratorHelper.java From vertx-codegen with Apache License 2.0 | 5 votes |
private MyProcessor(Function<CodeGen, R> f, Set<String> otherSupportedAnnotations) { this.f = f; this.supportedAnnotations = new HashSet<>(); this.supportedAnnotations.add(ProxyGen.class.getCanonicalName()); this.supportedAnnotations.add(VertxGen.class.getCanonicalName()); this.supportedAnnotations.add(DataObject.class.getCanonicalName()); this.supportedAnnotations.add(ModuleGen.class.getCanonicalName()); this.supportedAnnotations.addAll(otherSupportedAnnotations); }
Example #4
Source File: MapperGenBase.java From vertx-sql-client with Apache License 2.0 | 4 votes |
@Override public Collection<Class<? extends Annotation>> annotations() { return Collections.singletonList(DataObject.class); }
Example #5
Source File: ParametersMapperGen.java From vertx-sql-client with Apache License 2.0 | 4 votes |
@Override public Collection<Class<? extends Annotation>> annotations() { return Collections.singletonList(DataObject.class); }
Example #6
Source File: RowMapperGen.java From vertx-sql-client with Apache License 2.0 | 4 votes |
@Override public Collection<Class<? extends Annotation>> annotations() { return Collections.singletonList(DataObject.class); }
Example #7
Source File: DataObjectModel.java From vertx-codegen with Apache License 2.0 | 4 votes |
private void traverse() { DataObject ann = modelElt.getAnnotation(DataObject.class); this.generateConverter = ann.generateConverter(); this.publicConverter = ann.publicConverter(); this.inheritConverter = ann.inheritConverter(); this.isClass = modelElt.getKind() == ElementKind.CLASS; this.concrete = isClass && !modelElt.getModifiers().contains(Modifier.ABSTRACT); try { this.type = (ClassTypeInfo) typeFactory.create(modelElt.asType()); } catch (ClassCastException e) { throw new GenException(modelElt, "Data object must be a plain java class with no type parameters"); } Helper.checkUnderModule(this, "@VertxGen"); doc = docFactory.createDoc(modelElt); if (doc != null) doc.getBlockTags().stream().filter(tag -> tag.getName().equals("deprecated")).findFirst().ifPresent(tag -> deprecatedDesc = new Text(Helper.normalizeWhitespaces(tag.getValue())).map(Token.tagMapper(elementUtils, typeUtils, modelElt)) ); if (getModule() == null) { throw new GenException(modelElt, "Data object must have an ancestor package annotated with @ModuleGen"); } modelElt.getInterfaces().stream() .filter(superTM -> superTM instanceof DeclaredType && ((DeclaredType) superTM).asElement().getAnnotation(DataObject.class) != null) .map(e -> (ClassTypeInfo) typeFactory.create(e)).forEach(abstractSuperTypes::add); superTypes.addAll(abstractSuperTypes); TypeMirror superClass = modelElt.getSuperclass(); if (superClass instanceof DeclaredType && ((DeclaredType) superClass).asElement().getAnnotation(DataObject.class) != null) { superType = (ClassTypeInfo) typeFactory.create(superClass); superTypes.add(superType); } List<ExecutableElement> methodsElt = new ArrayList<>(); for (Element enclosedElt : elementUtils.getAllMembers(modelElt)) { switch (enclosedElt.getKind()) { case CONSTRUCTOR: ExecutableElement constrElt = (ExecutableElement) enclosedElt; processConstructor(constrElt); break; case METHOD: { ExecutableElement methodElt = (ExecutableElement) enclosedElt; if (methodElt.getSimpleName().toString().equals("toJson") && methodElt.getParameters().isEmpty() && typeFactory.create(methodElt.getReturnType()).getKind() == ClassKind.JSON_OBJECT) { hasToJsonMethod = true; } if (methodElt.getSimpleName().contentEquals("decode") && methodElt.getModifiers().containsAll(Arrays.asList(Modifier.STATIC, Modifier.PUBLIC)) && methodElt.getParameters().size() == 1 && typeFactory.create(methodElt.getParameters().get(0).asType()).getKind() == ClassKind.JSON_OBJECT && typeUtils.isSameType(methodElt.getReturnType(), this.modelElt.asType())) { hasDecodeStaticMethod = true; } if (methodElt.getAnnotation(GenIgnore.class) == null) { methodsElt.add(methodElt); } break; } } } processMethods(methodsElt); // Sort the properties so we do have a consistent order ArrayList<PropertyInfo> props = new ArrayList<>(propertyMap.values()); Collections.sort(props, (p1, p2) -> p1.name.compareTo(p2.name)); propertyMap.clear(); props.forEach(prop -> propertyMap.put(prop.name, prop)); }
Example #8
Source File: DataObjectHelperGen.java From vertx-codegen with Apache License 2.0 | 4 votes |
@Override public Collection<Class<? extends Annotation>> annotations() { return Collections.singletonList(DataObject.class); }
Example #9
Source File: DataObjectCheatsheetGen.java From vertx-codegen with Apache License 2.0 | 4 votes |
@Override public Collection<Class<? extends Annotation>> annotations() { return Arrays.asList(DataObject.class, ModuleGen.class); }
Example #10
Source File: TestGenerator.java From vertx-codegen with Apache License 2.0 | 4 votes |
@Override public Collection<Class<? extends Annotation>> annotations() { return Arrays.asList(DataObject.class, VertxGen.class); }
Example #11
Source File: TestGenerator.java From vertx-codegen with Apache License 2.0 | 4 votes |
@Override public Collection<Class<? extends Annotation>> annotations() { return Arrays.asList(DataObject.class, ModuleGen.class); }
Example #12
Source File: TestGenerator.java From vertx-codegen with Apache License 2.0 | 4 votes |
@Override public Collection<Class<? extends Annotation>> annotations() { return Arrays.asList(DataObject.class, ModuleGen.class, VertxGen.class); }