@Override public void visit(FieldDeclaration fd, List<EntityField> f) { if (fd.getAnnotations().stream().anyMatch(anno -> anno.getName().getName().equals("Column"))) { Class<?> type = null; switch (fd.getType().toString()) { case "String": type = String.class; break; case "Long": type = Long.class; break; case "Integer": type = Integer.class; break; case "boolean": type = boolean.class; break; } if (type == null) return; f.add(new EntityField( fd.getVariables().get(0).getId().getName(), type, fd.getAnnotations().stream().anyMatch(anno -> anno.getName().getName().equals("Id")))); } } }, entityFields);
@Override public FieldDeclaration doMerge(FieldDeclaration first, FieldDeclaration second) { FieldDeclaration fd = new FieldDeclaration(); fd.setJavaDoc(mergeSingle(first.getJavaDoc(),second.getJavaDoc())); fd.setType(mergeSingle(first.getType(),second.getType())); fd.setModifiers(mergeModifiers(first.getModifiers(),second.getModifiers())); fd.setAnnotations(mergeCollections(first.getAnnotations(),second.getAnnotations())); fd.setVariables(mergeListNoDuplicate(first.getVariables(),second.getVariables(),true)); return fd; }
public static FieldDeclaration mergeField(FieldDeclaration one, FieldDeclaration two) { if (isAllNull(one, two)) return null; FieldDeclaration fd = null; if (isAllNotNull(one, two)) { fd = new FieldDeclaration(); fd.setType(mergeSelective(one.getType(), two.getType())); fd.setComment(mergeSelective(one.getComment(), two.getComment())); fd.setAnnotations(mergeListNoDuplicate(one.getAnnotations(), two.getAnnotations())); fd.setModifiers(mergeModifiers(one.getModifiers(), two.getModifiers())); fd.setJavaDoc(mergeSelective(one.getJavaDoc(), two.getJavaDoc())); fd.setVariables(mergeListNoDuplicate(one.getVariables(), two.getVariables())); LOG.info("merge FieldDeclaration --> {}", fd.getVariables()); } else { fd = findFirstNotNull(one, two); LOG.info("add FieldDeclaration --> {}", fd.getVariables()); } return fd; }