From e4e27922bb5f7f35801dd84a021d3f981bcfebcf Mon Sep 17 00:00:00 2001 From: Ryan Heaton Date: Mon, 19 Sep 2016 11:20:01 -0600 Subject: [PATCH 01/12] skeleton for lombok module to support #501 --- lombok/pom.xml | 26 ++++++++++++++ .../modules/lombok/LombokModule.java | 34 +++++++++++++++++++ ...bcohesion.enunciate.module.EnunciateModule | 1 + pom.xml | 8 +++++ 4 files changed, 69 insertions(+) create mode 100644 lombok/pom.xml create mode 100644 lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokModule.java create mode 100644 lombok/src/main/resources/META-INF/services/com.webcohesion.enunciate.module.EnunciateModule diff --git a/lombok/pom.xml b/lombok/pom.xml new file mode 100644 index 000000000..e9b4769fd --- /dev/null +++ b/lombok/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + com.webcohesion.enunciate + enunciate-parent + 2.7.0-SNAPSHOT + + + enunciate-lombok + Enunciate - Project Lombok Support + Support for project Lombok. + + + + ${project.groupId} + enunciate-core + ${project.version} + + + org.projectlombok + lombok + + + + diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokModule.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokModule.java new file mode 100644 index 000000000..c2d262f99 --- /dev/null +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokModule.java @@ -0,0 +1,34 @@ +package com.webcohesion.enunciate.modules.lombok; + +import com.webcohesion.enunciate.EnunciateContext; +import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import com.webcohesion.enunciate.module.BasicEnunicateModule; +import com.webcohesion.enunciate.module.ContextModifyingModule; +import lombok.Data; + +import javax.lang.model.element.Element; +import java.util.Set; + +/** + * @author Ryan Heaton + */ +public class LombokModule extends BasicEnunicateModule implements ContextModifyingModule { + + @Override + public String getName() { + return "lombok"; + } + + @Override + public void call(EnunciateContext context) { + Set apiElements = context.getApiElements(); + for (Element apiElement : apiElements) { + if (apiElement instanceof DecoratedTypeElement && apiElement.getAnnotation(Data.class) != null) { + DecoratedTypeElement typeElement = (DecoratedTypeElement) apiElement; + //todo: modify the element as needed + + } + } + } + +} diff --git a/lombok/src/main/resources/META-INF/services/com.webcohesion.enunciate.module.EnunciateModule b/lombok/src/main/resources/META-INF/services/com.webcohesion.enunciate.module.EnunciateModule new file mode 100644 index 000000000..ac2c8ccd8 --- /dev/null +++ b/lombok/src/main/resources/META-INF/services/com.webcohesion.enunciate.module.EnunciateModule @@ -0,0 +1 @@ +com.webcohesion.enunciate.modules.lombok.LombokModule \ No newline at end of file diff --git a/pom.xml b/pom.xml index 559d74fd3..6a47b397c 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,8 @@ core rt-util javac-support + lombok + jaxb jackson jackson1 @@ -85,6 +87,7 @@ 2.5 2.7 4.12 + 1.16.10 2.2.1 1.3 3.4 @@ -593,6 +596,11 @@ your path down the rabbit hole. ${validation-api.version} + + org.projectlombok + lombok + ${lombok.version} + From 3c911f5882a68068a844ce51106a1853acaef827 Mon Sep 17 00:00:00 2001 From: Ryan Heaton Date: Thu, 22 Sep 2016 14:42:24 -0600 Subject: [PATCH 02/12] pushing down decorated processing environment to various members --- .../webcohesion/enunciate/util/TypeHintUtils.java | 4 ++-- .../modules/jackson/model/util/MapType.java | 4 ++-- .../modules/jackson1/model/util/MapType.java | 4 ++-- .../enunciate/javac/decorations/Annotations.java | 5 ++--- .../javac/decorations/DecoratedElements.java | 6 ++---- .../javac/decorations/DecoratedTypes.java | 7 +++---- .../javac/decorations/ElementDecorator.java | 13 +++++++------ .../javac/decorations/TypeMirrorDecorator.java | 9 ++++----- .../element/DecoratedAnnotationMirror.java | 4 +++- .../decorations/element/DecoratedElement.java | 9 ++------- .../element/DecoratedExecutableElement.java | 4 ++-- .../element/DecoratedPackageElement.java | 5 +++-- .../decorations/element/DecoratedTypeElement.java | 4 ++-- .../element/DecoratedTypeParameterElement.java | 4 ++-- .../element/DecoratedVariableElement.java | 5 +++-- .../decorations/type/DecoratedArrayType.java | 4 ++-- .../decorations/type/DecoratedDeclaredType.java | 3 ++- .../decorations/type/DecoratedErrorType.java | 4 +++- .../decorations/type/DecoratedExecutableType.java | 4 ++-- .../javac/decorations/type/DecoratedNoType.java | 5 +++-- .../javac/decorations/type/DecoratedNullType.java | 5 +++-- .../decorations/type/DecoratedPrimitiveType.java | 5 +++-- .../decorations/type/DecoratedReferenceType.java | 5 +++-- .../decorations/type/DecoratedTypeMirror.java | 15 ++++++--------- .../decorations/type/DecoratedTypeVariable.java | 4 ++-- .../decorations/type/DecoratedWildcardType.java | 4 ++-- .../enunciate/modules/jaxb/model/Schema.java | 4 ++-- .../modules/jaxb/model/util/MapType.java | 5 ++--- .../jaxrs/model/ResourceEntityParameter.java | 4 ++-- 29 files changed, 78 insertions(+), 80 deletions(-) diff --git a/core/src/main/java/com/webcohesion/enunciate/util/TypeHintUtils.java b/core/src/main/java/com/webcohesion/enunciate/util/TypeHintUtils.java index ff9a8eacd..5a0ed3350 100644 --- a/core/src/main/java/com/webcohesion/enunciate/util/TypeHintUtils.java +++ b/core/src/main/java/com/webcohesion/enunciate/util/TypeHintUtils.java @@ -15,11 +15,11 @@ */ package com.webcohesion.enunciate.util; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.metadata.rs.TypeHint; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.MirroredTypeException; @@ -34,7 +34,7 @@ public class TypeHintUtils { private TypeHintUtils() {} - public static TypeMirror getTypeHint(TypeHint hintInfo, ProcessingEnvironment env, TypeMirror defaultValue) { + public static TypeMirror getTypeHint(TypeHint hintInfo, DecoratedProcessingEnvironment env, TypeMirror defaultValue) { TypeMirror typeMirror; try { Class hint = hintInfo.value(); diff --git a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/util/MapType.java b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/util/MapType.java index 586db5626..67ed5c9bd 100644 --- a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/util/MapType.java +++ b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/util/MapType.java @@ -15,12 +15,12 @@ */ package com.webcohesion.enunciate.modules.jackson.model.util; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType; import com.webcohesion.enunciate.javac.decorations.type.TypeMirrorUtils; import com.webcohesion.enunciate.modules.jackson.EnunciateJacksonContext; import com.webcohesion.enunciate.modules.jackson.model.adapters.AdapterType; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; @@ -45,7 +45,7 @@ public class MapType extends DecoratedDeclaredType { private TypeMirror valueType; private DeclaredType originalType; - private MapType(DeclaredType mapType, ProcessingEnvironment env) { + private MapType(DeclaredType mapType, DecoratedProcessingEnvironment env) { super(mapType, env); this.originalType = mapType; } diff --git a/jackson1/src/main/java/com/webcohesion/enunciate/modules/jackson1/model/util/MapType.java b/jackson1/src/main/java/com/webcohesion/enunciate/modules/jackson1/model/util/MapType.java index 934c0aac6..8e2d597ec 100644 --- a/jackson1/src/main/java/com/webcohesion/enunciate/modules/jackson1/model/util/MapType.java +++ b/jackson1/src/main/java/com/webcohesion/enunciate/modules/jackson1/model/util/MapType.java @@ -15,12 +15,12 @@ */ package com.webcohesion.enunciate.modules.jackson1.model.util; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType; import com.webcohesion.enunciate.javac.decorations.type.TypeMirrorUtils; import com.webcohesion.enunciate.modules.jackson1.EnunciateJackson1Context; import com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; @@ -45,7 +45,7 @@ public class MapType extends DecoratedDeclaredType { private TypeMirror valueType; private DeclaredType originalType; - private MapType(DeclaredType mapType, ProcessingEnvironment env) { + private MapType(DeclaredType mapType, DecoratedProcessingEnvironment env) { super(mapType, env); this.originalType = mapType; } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/Annotations.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/Annotations.java index 9a862d52d..ee1de6762 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/Annotations.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/Annotations.java @@ -18,7 +18,6 @@ import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.javac.decorations.type.TypeMirrorUtils; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; @@ -33,11 +32,11 @@ public class Annotations { private Annotations(){} - public static DecoratedTypeMirror mirrorOf(Callable> annotationValueFunction, ProcessingEnvironment env) { + public static DecoratedTypeMirror mirrorOf(Callable> annotationValueFunction, DecoratedProcessingEnvironment env) { return mirrorOf(annotationValueFunction, env, null); } - public static DecoratedTypeMirror mirrorOf(Callable> annotationValueFunction, ProcessingEnvironment env, Class emptyClass) { + public static DecoratedTypeMirror mirrorOf(Callable> annotationValueFunction, DecoratedProcessingEnvironment env, Class emptyClass) { try { Class clazz = annotationValueFunction.call(); if (emptyClass != null && emptyClass.equals(clazz)) { diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java index 3c53bae25..df0ebd9dd 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java @@ -19,9 +19,7 @@ import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; -import com.webcohesion.enunciate.javac.javadoc.JavaDoc; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.*; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; @@ -37,9 +35,9 @@ public class DecoratedElements implements Elements { private final Elements delegate; - private final ProcessingEnvironment env; + private final DecoratedProcessingEnvironment env; - public DecoratedElements(Elements delegate, ProcessingEnvironment env) { + public DecoratedElements(Elements delegate, DecoratedProcessingEnvironment env) { this.env = env; while (delegate instanceof DecoratedElements) { delegate = ((DecoratedElements) delegate).delegate; diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedTypes.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedTypes.java index fd249ac78..f52e5a59e 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedTypes.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedTypes.java @@ -22,7 +22,6 @@ import com.webcohesion.enunciate.javac.decorations.type.DecoratedPrimitiveType; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.type.*; @@ -35,11 +34,11 @@ public class DecoratedTypes implements Types { private final Types delegate; - private final ProcessingEnvironment env; + private final DecoratedProcessingEnvironment env; - public DecoratedTypes(Types delegate, ProcessingEnvironment env) { + public DecoratedTypes(Types delegate, DecoratedProcessingEnvironment env) { while (delegate instanceof DecoratedTypes) { - delegate = ((DecoratedTypes) env).delegate; + delegate = ((DecoratedTypes) delegate).delegate; } this.delegate = delegate; diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/ElementDecorator.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/ElementDecorator.java index cc5b5a0d5..d9a9e4504 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/ElementDecorator.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/ElementDecorator.java @@ -17,7 +17,6 @@ import com.webcohesion.enunciate.javac.decorations.element.*; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.*; import javax.lang.model.util.SimpleElementVisitor6; import java.util.ArrayList; @@ -31,9 +30,9 @@ @SuppressWarnings ( "unchecked" ) public class ElementDecorator extends SimpleElementVisitor6 { - private final ProcessingEnvironment env; + private final DecoratedProcessingEnvironment env; - private ElementDecorator(ProcessingEnvironment env) { + private ElementDecorator(DecoratedProcessingEnvironment env) { this.env = env; } @@ -42,9 +41,10 @@ private ElementDecorator(ProcessingEnvironment env) { * Decorates a declaration. * * @param element The declaration to decorate. + * @param env The processing environment. * @return The decorated declaration. */ - public static E decorate(E element, ProcessingEnvironment env) { + public static E decorate(E element, DecoratedProcessingEnvironment env) { if (element == null) { return null; } @@ -61,10 +61,11 @@ public static E decorate(E element, ProcessingEnvironment en * Decorates a collection of elements. * * @param elements The elements to decorate. + * @param env The decorated processing environment. * @return The decorated elements. */ @SuppressWarnings({"unchecked"}) - public static List decorate(List elements, ProcessingEnvironment env) { + public static List decorate(List elements, DecoratedProcessingEnvironment env) { if (elements == null) { return null; } @@ -83,7 +84,7 @@ public static List decorate(List elements, ProcessingE * @param env The processing environment. * @return The collection of decorated annotation mirrors. */ - public static List decorateAnnotationMirrors(List annotationMirrors, ProcessingEnvironment env) { + public static List decorateAnnotationMirrors(List annotationMirrors, DecoratedProcessingEnvironment env) { if (annotationMirrors == null) { return null; } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/TypeMirrorDecorator.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/TypeMirrorDecorator.java index 9bc1c37b5..9fdf410b8 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/TypeMirrorDecorator.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/TypeMirrorDecorator.java @@ -17,7 +17,6 @@ import com.webcohesion.enunciate.javac.decorations.type.*; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.type.*; import javax.lang.model.util.SimpleTypeVisitor6; import java.util.ArrayList; @@ -31,9 +30,9 @@ @SuppressWarnings({"unchecked"}) public class TypeMirrorDecorator extends SimpleTypeVisitor6 { - private final ProcessingEnvironment env; + private final DecoratedProcessingEnvironment env; - public TypeMirrorDecorator(ProcessingEnvironment env) { + public TypeMirrorDecorator(DecoratedProcessingEnvironment env) { this.env = env; } @@ -44,7 +43,7 @@ public TypeMirrorDecorator(ProcessingEnvironment env) { * @param env The environment. * @return The decorated type mirror. */ - public static T decorate(T typeMirror, ProcessingEnvironment env) { + public static T decorate(T typeMirror, DecoratedProcessingEnvironment env) { if (typeMirror == null) { return null; } @@ -64,7 +63,7 @@ public static T decorate(T typeMirror, ProcessingEnvironm * @param env The environment. * @return The collection of decorated type mirrors. */ - public static List decorate(List typeMirrors, ProcessingEnvironment env) { + public static List decorate(List typeMirrors, DecoratedProcessingEnvironment env) { if (typeMirrors == null) { return null; } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedAnnotationMirror.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedAnnotationMirror.java index 171699a23..253f25ddc 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedAnnotationMirror.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedAnnotationMirror.java @@ -15,6 +15,8 @@ */ package com.webcohesion.enunciate.javac.decorations.element; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; + import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; @@ -30,7 +32,7 @@ public class DecoratedAnnotationMirror implements AnnotationMirror { private final AnnotationMirror delegate; private final ProcessingEnvironment env; - public DecoratedAnnotationMirror(AnnotationMirror delegate, ProcessingEnvironment env) { + public DecoratedAnnotationMirror(AnnotationMirror delegate, DecoratedProcessingEnvironment env) { if (delegate == null) { throw new NullPointerException("A delegate must be provided."); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java index 509d0688f..a1f1ed682 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java @@ -22,7 +22,6 @@ import com.webcohesion.enunciate.javac.javadoc.JavaDocTagHandler; import com.webcohesion.enunciate.javac.javadoc.JavaDocTagHandlerFactory; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.*; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; @@ -41,13 +40,9 @@ public class DecoratedElement implements Element { private List annotationMirrors; private Map annotations = null; - public DecoratedElement(E delegate, ProcessingEnvironment env) { - if (!(env instanceof DecoratedProcessingEnvironment)) { - env = new DecoratedProcessingEnvironment(env); - } - + public DecoratedElement(E delegate, DecoratedProcessingEnvironment env) { this.delegate = delegate; - this.env = (DecoratedProcessingEnvironment) env; + this.env = env; } protected JavaDoc constructJavaDoc(String docComment, JavaDocTagHandler tagHandler) { diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedExecutableElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedExecutableElement.java index f5ceefd70..4f4d4485b 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedExecutableElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedExecutableElement.java @@ -15,6 +15,7 @@ */ package com.webcohesion.enunciate.javac.decorations.element; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.ElementDecorator; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; import com.webcohesion.enunciate.javac.decorations.type.DecoratedReferenceType; @@ -22,7 +23,6 @@ import com.webcohesion.enunciate.javac.javadoc.JavaDoc; import com.webcohesion.enunciate.javac.javadoc.JavaDocTagHandler; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.*; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; @@ -46,7 +46,7 @@ public class DecoratedExecutableElement extends DecoratedElement typeParameters; private TypeMirror typeMirror; - public DecoratedExecutableElement(ExecutableElement delegate, ProcessingEnvironment env) { + public DecoratedExecutableElement(ExecutableElement delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedPackageElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedPackageElement.java index 4997d7c7d..4c70b4f8a 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedPackageElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedPackageElement.java @@ -15,7 +15,8 @@ */ package com.webcohesion.enunciate.javac.decorations.element; -import javax.annotation.processing.ProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; + import javax.lang.model.element.ElementVisitor; import javax.lang.model.element.Name; import javax.lang.model.element.PackageElement; @@ -26,7 +27,7 @@ */ public class DecoratedPackageElement extends DecoratedElement implements PackageElement { - public DecoratedPackageElement(PackageElement delegate, ProcessingEnvironment env) { + public DecoratedPackageElement(PackageElement delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java index 553446de6..2ec96f254 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java @@ -15,10 +15,10 @@ */ package com.webcohesion.enunciate.javac.decorations.element; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.ElementDecorator; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.*; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; @@ -48,7 +48,7 @@ public class DecoratedTypeElement extends DecoratedElement implemen private List constructors; private List enumConstants; - public DecoratedTypeElement(TypeElement delegate, ProcessingEnvironment env) { + public DecoratedTypeElement(TypeElement delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeParameterElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeParameterElement.java index d75080544..ff39415b7 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeParameterElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeParameterElement.java @@ -15,10 +15,10 @@ */ package com.webcohesion.enunciate.javac.decorations.element; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.ElementDecorator; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementVisitor; import javax.lang.model.element.TypeParameterElement; @@ -33,7 +33,7 @@ public class DecoratedTypeParameterElement extends DecoratedElement bounds; - public DecoratedTypeParameterElement(TypeParameterElement delegate, ProcessingEnvironment env) { + public DecoratedTypeParameterElement(TypeParameterElement delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedVariableElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedVariableElement.java index 7c35138bd..873ca0f72 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedVariableElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedVariableElement.java @@ -15,7 +15,8 @@ */ package com.webcohesion.enunciate.javac.decorations.element; -import javax.annotation.processing.ProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; + import javax.lang.model.element.ElementVisitor; import javax.lang.model.element.VariableElement; @@ -24,7 +25,7 @@ */ public class DecoratedVariableElement extends DecoratedElement implements VariableElement{ - public DecoratedVariableElement(VariableElement delegate, ProcessingEnvironment env) { + public DecoratedVariableElement(VariableElement delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedArrayType.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedArrayType.java index 65cba8e7b..c508fa6d2 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedArrayType.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedArrayType.java @@ -15,9 +15,9 @@ */ package com.webcohesion.enunciate.javac.decorations.type; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.type.ArrayType; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVisitor; @@ -27,7 +27,7 @@ */ public class DecoratedArrayType extends DecoratedReferenceType implements ArrayType { - public DecoratedArrayType(ArrayType delegate, ProcessingEnvironment env) { + public DecoratedArrayType(ArrayType delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedDeclaredType.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedDeclaredType.java index 2a6f38b18..3c773a939 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedDeclaredType.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedDeclaredType.java @@ -15,6 +15,7 @@ */ package com.webcohesion.enunciate.javac.decorations.type; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.ElementDecorator; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; @@ -34,7 +35,7 @@ */ public class DecoratedDeclaredType extends DecoratedReferenceType implements DeclaredType { - public DecoratedDeclaredType(DeclaredType delegate, ProcessingEnvironment env) { + public DecoratedDeclaredType(DeclaredType delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedErrorType.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedErrorType.java index dac0ae2c5..55bcad113 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedErrorType.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedErrorType.java @@ -15,6 +15,8 @@ */ package com.webcohesion.enunciate.javac.decorations.type; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; + import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.type.ErrorType; import javax.lang.model.type.TypeMirror; @@ -28,7 +30,7 @@ */ public class DecoratedErrorType extends DecoratedDeclaredType implements ErrorType { - public DecoratedErrorType(ErrorType delegate, ProcessingEnvironment env) { + public DecoratedErrorType(ErrorType delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedExecutableType.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedExecutableType.java index adfd72da6..94ab9c7ca 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedExecutableType.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedExecutableType.java @@ -15,9 +15,9 @@ */ package com.webcohesion.enunciate.javac.decorations.type; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.type.ExecutableType; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; @@ -32,7 +32,7 @@ */ public class DecoratedExecutableType extends DecoratedTypeMirror implements ExecutableType { - public DecoratedExecutableType(ExecutableType delegate, ProcessingEnvironment env) { + public DecoratedExecutableType(ExecutableType delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedNoType.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedNoType.java index cb0cb53fd..0bfa249a1 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedNoType.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedNoType.java @@ -15,7 +15,8 @@ */ package com.webcohesion.enunciate.javac.decorations.type; -import javax.annotation.processing.ProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; + import javax.lang.model.type.NoType; import javax.lang.model.type.TypeVisitor; @@ -24,7 +25,7 @@ */ public class DecoratedNoType extends DecoratedTypeMirror implements NoType { - public DecoratedNoType(NoType delegate, ProcessingEnvironment env) { + public DecoratedNoType(NoType delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedNullType.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedNullType.java index 927d041a2..ab762a96e 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedNullType.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedNullType.java @@ -15,7 +15,8 @@ */ package com.webcohesion.enunciate.javac.decorations.type; -import javax.annotation.processing.ProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; + import javax.lang.model.type.NullType; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVisitor; @@ -25,7 +26,7 @@ */ public class DecoratedNullType extends DecoratedReferenceType implements NullType { - public DecoratedNullType(NullType delegate, ProcessingEnvironment env) { + public DecoratedNullType(NullType delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedPrimitiveType.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedPrimitiveType.java index dc3690dc3..07a33d008 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedPrimitiveType.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedPrimitiveType.java @@ -16,7 +16,8 @@ package com.webcohesion.enunciate.javac.decorations.type; -import javax.annotation.processing.ProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; + import javax.lang.model.type.PrimitiveType; import javax.lang.model.type.TypeVisitor; @@ -31,7 +32,7 @@ */ public class DecoratedPrimitiveType extends DecoratedTypeMirror implements PrimitiveType { - public DecoratedPrimitiveType(PrimitiveType delegate, ProcessingEnvironment env) { + public DecoratedPrimitiveType(PrimitiveType delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedReferenceType.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedReferenceType.java index 81caa6f63..152eaa05c 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedReferenceType.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedReferenceType.java @@ -15,7 +15,8 @@ */ package com.webcohesion.enunciate.javac.decorations.type; -import javax.annotation.processing.ProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; + import javax.lang.model.type.ReferenceType; /** @@ -23,7 +24,7 @@ */ public class DecoratedReferenceType extends DecoratedTypeMirror implements ReferenceType { - public DecoratedReferenceType(T delegate, ProcessingEnvironment env) { + public DecoratedReferenceType(T delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java index ce67f5dd0..556d92015 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java @@ -17,11 +17,12 @@ import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; -import javax.lang.model.type.*; -import java.util.Collection; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.type.TypeVisitor; @SuppressWarnings ( "unchecked" ) public class DecoratedTypeMirror implements TypeMirror { @@ -30,17 +31,13 @@ public class DecoratedTypeMirror implements TypeMirror { protected final DecoratedProcessingEnvironment env; private String docComment = ""; - public DecoratedTypeMirror(T delegate, ProcessingEnvironment env) { + public DecoratedTypeMirror(T delegate, DecoratedProcessingEnvironment env) { while (delegate instanceof DecoratedTypeMirror) { delegate = (T) ((DecoratedTypeMirror) delegate).delegate; } - if (!(env instanceof DecoratedProcessingEnvironment)) { - env = new DecoratedProcessingEnvironment(env); - } - this.delegate = delegate; - this.env = (DecoratedProcessingEnvironment) env; + this.env = env; } @Override diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeVariable.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeVariable.java index 2c99bc0ea..f1c62f20c 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeVariable.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeVariable.java @@ -15,10 +15,10 @@ */ package com.webcohesion.enunciate.javac.decorations.type; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.ElementDecorator; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; @@ -29,7 +29,7 @@ */ public class DecoratedTypeVariable extends DecoratedReferenceType implements TypeVariable { - public DecoratedTypeVariable(TypeVariable delegate, ProcessingEnvironment env) { + public DecoratedTypeVariable(TypeVariable delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedWildcardType.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedWildcardType.java index 6df4a193a..643cbae76 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedWildcardType.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedWildcardType.java @@ -15,9 +15,9 @@ */ package com.webcohesion.enunciate.javac.decorations.type; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVisitor; import javax.lang.model.type.WildcardType; @@ -27,7 +27,7 @@ */ public class DecoratedWildcardType extends DecoratedTypeMirror implements WildcardType { - public DecoratedWildcardType(WildcardType delegate, ProcessingEnvironment env) { + public DecoratedWildcardType(WildcardType delegate, DecoratedProcessingEnvironment env) { super(delegate, env); } diff --git a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/Schema.java b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/Schema.java index 37b42a6ff..53b636125 100644 --- a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/Schema.java +++ b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/Schema.java @@ -17,9 +17,9 @@ import com.webcohesion.enunciate.facets.Facet; import com.webcohesion.enunciate.facets.HasFacets; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.element.DecoratedPackageElement; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.PackageElement; import javax.xml.bind.annotation.*; import java.util.HashMap; @@ -41,7 +41,7 @@ public class Schema extends DecoratedPackageElement implements Comparable facets; - public Schema(PackageElement delegate, ProcessingEnvironment env) { + public Schema(PackageElement delegate, DecoratedProcessingEnvironment env) { super(delegate, env); this.pckg = delegate; this.xmlSchema = delegate != null ? delegate.getAnnotation(XmlSchema.class) : null; diff --git a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/util/MapType.java b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/util/MapType.java index 7b0d3ee3d..7f0855c9f 100644 --- a/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/util/MapType.java +++ b/jaxb/src/main/java/com/webcohesion/enunciate/modules/jaxb/model/util/MapType.java @@ -15,14 +15,13 @@ */ package com.webcohesion.enunciate.modules.jaxb.model.util; -import com.webcohesion.enunciate.EnunciateException; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType; import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; import com.webcohesion.enunciate.javac.decorations.type.TypeMirrorUtils; import com.webcohesion.enunciate.modules.jaxb.EnunciateJaxbContext; import com.webcohesion.enunciate.modules.jaxb.model.adapters.AdapterType; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; @@ -47,7 +46,7 @@ public class MapType extends DecoratedDeclaredType { private TypeMirror valueType; private DeclaredType originalType; - private MapType(DeclaredType mapType, ProcessingEnvironment env) { + private MapType(DeclaredType mapType, DecoratedProcessingEnvironment env) { super(mapType, env); this.originalType = mapType; } diff --git a/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/ResourceEntityParameter.java b/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/ResourceEntityParameter.java index a99c615fa..87861d92e 100644 --- a/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/ResourceEntityParameter.java +++ b/jaxrs/src/main/java/com/webcohesion/enunciate/modules/jaxrs/model/ResourceEntityParameter.java @@ -15,6 +15,7 @@ */ package com.webcohesion.enunciate.modules.jaxrs.model; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedVariableElement; @@ -24,7 +25,6 @@ import com.webcohesion.enunciate.modules.jaxrs.EnunciateJaxrsContext; import com.webcohesion.enunciate.util.TypeHintUtils; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; @@ -74,7 +74,7 @@ public ResourceEntityParameter(ResourceMethod method, VariableElement delegate, } } - public ResourceEntityParameter(Element delegate, TypeMirror type, ProcessingEnvironment env) { + public ResourceEntityParameter(Element delegate, TypeMirror type, DecoratedProcessingEnvironment env) { super(delegate, env); this.type = type; } From 070ec24bc73bf7637d95acbb1c537281bc3c0fc2 Mon Sep 17 00:00:00 2001 From: Ryan Heaton Date: Thu, 22 Sep 2016 15:16:28 -0600 Subject: [PATCH 03/12] support for pluggable decoration modules --- .../EnunciateAnnotationProcessor.java | 25 +++++++++----- .../module/ContextModifyingModule.java | 13 ++++++++ .../AnnotationMirrorDecoration.java | 17 ++++++++++ .../DecoratedProcessingEnvironment.java | 23 +++++++++++-- .../javac/decorations/ElementDecoration.java | 17 ++++++++++ .../decorations/TypeMirrorDecoration.java | 17 ++++++++++ .../element/DecoratedAnnotationMirror.java | 7 ++++ .../decorations/element/DecoratedElement.java | 7 ++++ .../decorations/type/DecoratedTypeMirror.java | 7 ++++ .../modules/lombok/LombokDecoration.java | 27 +++++++++++++++ .../modules/lombok/LombokModule.java | 33 ++++++++++++------- 11 files changed, 171 insertions(+), 22 deletions(-) create mode 100644 javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/AnnotationMirrorDecoration.java create mode 100644 javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/ElementDecoration.java create mode 100644 javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/TypeMirrorDecoration.java create mode 100644 lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java diff --git a/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java b/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java index bea3acabc..3f7372af9 100644 --- a/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java +++ b/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java @@ -15,9 +15,8 @@ */ package com.webcohesion.enunciate; -import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; -import com.webcohesion.enunciate.javac.decorations.DecoratedRoundEnvironment; -import com.webcohesion.enunciate.javac.decorations.ElementDecorator; +import com.webcohesion.enunciate.javac.decorations.*; +import com.webcohesion.enunciate.module.ContextModifyingModule; import com.webcohesion.enunciate.module.EnunciateModule; import org.jgrapht.DirectedGraph; import org.jgrapht.graph.DefaultEdge; @@ -28,10 +27,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Ryan Heaton @@ -59,12 +55,25 @@ public SourceVersion getSupportedSourceVersion() { public synchronized void init(ProcessingEnvironment processingEnv) { super.init(processingEnv); + //set up the processing environment. + ArrayList elementDecorations = new ArrayList(); + ArrayList typeMirrorDecorations = new ArrayList(); + ArrayList annotationMirrorDecorations = new ArrayList(); + DecoratedProcessingEnvironment processingEnvironment = new DecoratedProcessingEnvironment(processingEnv, elementDecorations, typeMirrorDecorations, annotationMirrorDecorations); + //construct a context. - this.context = new EnunciateContext(new DecoratedProcessingEnvironment(processingEnv), this.enunciate.getLogger(), this.enunciate.getApiRegistry(), this.enunciate.getConfiguration(), this.enunciate.getIncludePatterns(), this.enunciate.getExcludePatterns()); + this.context = new EnunciateContext(processingEnvironment, this.enunciate.getLogger(), this.enunciate.getApiRegistry(), this.enunciate.getConfiguration(), this.enunciate.getIncludePatterns(), this.enunciate.getExcludePatterns()); //initialize the modules. for (EnunciateModule module : this.enunciate.getModules()) { module.init(this.context); + + if (module instanceof ContextModifyingModule) { + ContextModifyingModule contextModifier = (ContextModifyingModule) module; + elementDecorations.addAll(contextModifier.getElementDecorations()); + typeMirrorDecorations.addAll(contextModifier.getTypeMirrorDecorations()); + annotationMirrorDecorations.addAll(contextModifier.getAnnotationMirrorDecorations()); + } } } diff --git a/core/src/main/java/com/webcohesion/enunciate/module/ContextModifyingModule.java b/core/src/main/java/com/webcohesion/enunciate/module/ContextModifyingModule.java index 348214979..e0841effd 100644 --- a/core/src/main/java/com/webcohesion/enunciate/module/ContextModifyingModule.java +++ b/core/src/main/java/com/webcohesion/enunciate/module/ContextModifyingModule.java @@ -1,9 +1,22 @@ package com.webcohesion.enunciate.module; +import com.webcohesion.enunciate.javac.decorations.AnnotationMirrorDecoration; +import com.webcohesion.enunciate.javac.decorations.ElementDecoration; +import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecoration; + +import java.util.List; + /** * Marker interface for designating a module as one that modifies the Enunciate context. * * @author Ryan Heaton */ public interface ContextModifyingModule extends EnunciateModule { + + List getElementDecorations(); + + List getTypeMirrorDecorations(); + + List getAnnotationMirrorDecorations(); + } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/AnnotationMirrorDecoration.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/AnnotationMirrorDecoration.java new file mode 100644 index 000000000..76e468688 --- /dev/null +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/AnnotationMirrorDecoration.java @@ -0,0 +1,17 @@ +package com.webcohesion.enunciate.javac.decorations; + +import com.webcohesion.enunciate.javac.decorations.element.DecoratedAnnotationMirror; + +/** + * @author Ryan Heaton + */ +public interface AnnotationMirrorDecoration { + + /** + * Apply this decoration to the given decorated annotation mirror. + * + * @param mirror The mirror to decorate. + */ + void applyTo(DecoratedAnnotationMirror mirror); + +} diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedProcessingEnvironment.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedProcessingEnvironment.java index 7ee8d4789..2d2461a03 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedProcessingEnvironment.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedProcessingEnvironment.java @@ -28,6 +28,7 @@ import javax.lang.model.element.Element; import javax.lang.model.util.Elements; import javax.lang.model.util.Types; +import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -40,8 +41,14 @@ public class DecoratedProcessingEnvironment implements ProcessingEnvironment { private final ProcessingEnvironment delegate; private final Map properties = new ConcurrentHashMap(); private final Trees trees; - - public DecoratedProcessingEnvironment(ProcessingEnvironment delegate) { + private final List elementDecorations; + private final List typeMirrorDecorations; + private final List annotationMirrorDecorations; + + public DecoratedProcessingEnvironment(ProcessingEnvironment delegate, List elementDecorations, List typeMirrorDecorations, List annotationMirrorDecorations) { + this.elementDecorations = elementDecorations; + this.typeMirrorDecorations = typeMirrorDecorations; + this.annotationMirrorDecorations = annotationMirrorDecorations; while (delegate instanceof DecoratedProcessingEnvironment) { delegate = ((DecoratedProcessingEnvironment) delegate).delegate; } @@ -110,4 +117,16 @@ public SourcePosition findSourcePosition(Element element) { return null; } } + + public List getElementDecorations() { + return elementDecorations; + } + + public List getTypeMirrorDecorations() { + return typeMirrorDecorations; + } + + public List getAnnotationMirrorDecorations() { + return annotationMirrorDecorations; + } } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/ElementDecoration.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/ElementDecoration.java new file mode 100644 index 000000000..f09d08c78 --- /dev/null +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/ElementDecoration.java @@ -0,0 +1,17 @@ +package com.webcohesion.enunciate.javac.decorations; + +import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; + +/** + * @author Ryan Heaton + */ +public interface ElementDecoration { + + /** + * Apply this decoration to the given decorated element. + * + * @param e The element to decorate. + */ + void applyTo(DecoratedElement e); + +} diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/TypeMirrorDecoration.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/TypeMirrorDecoration.java new file mode 100644 index 000000000..ce24a86e0 --- /dev/null +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/TypeMirrorDecoration.java @@ -0,0 +1,17 @@ +package com.webcohesion.enunciate.javac.decorations; + +import com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror; + +/** + * @author Ryan Heaton + */ +public interface TypeMirrorDecoration { + + /** + * Apply this decoration to the given decorated type mirror. + * + * @param mirror The mirror to decorate. + */ + void applyTo(DecoratedTypeMirror mirror); + +} diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedAnnotationMirror.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedAnnotationMirror.java index 253f25ddc..1bff4c910 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedAnnotationMirror.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedAnnotationMirror.java @@ -15,6 +15,7 @@ */ package com.webcohesion.enunciate.javac.decorations.element; +import com.webcohesion.enunciate.javac.decorations.AnnotationMirrorDecoration; import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import javax.annotation.processing.ProcessingEnvironment; @@ -48,6 +49,12 @@ public DecoratedAnnotationMirror(AnnotationMirror delegate, DecoratedProcessingE this.delegate = delegate; this.env = env; + + if (env.getAnnotationMirrorDecorations() != null) { + for (AnnotationMirrorDecoration decoration : env.getAnnotationMirrorDecorations()) { + decoration.applyTo(this); + } + } } public DeclaredType getAnnotationType() { diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java index a1f1ed682..07bfcfcf4 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java @@ -16,6 +16,7 @@ package com.webcohesion.enunciate.javac.decorations.element; import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.ElementDecoration; import com.webcohesion.enunciate.javac.decorations.ElementDecorator; import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecorator; import com.webcohesion.enunciate.javac.javadoc.JavaDoc; @@ -43,6 +44,12 @@ public class DecoratedElement implements Element { public DecoratedElement(E delegate, DecoratedProcessingEnvironment env) { this.delegate = delegate; this.env = env; + + if (this.env.getElementDecorations() != null) { + for (ElementDecoration elementDecoration : this.env.getElementDecorations()) { + elementDecoration.applyTo(this); + } + } } protected JavaDoc constructJavaDoc(String docComment, JavaDocTagHandler tagHandler) { diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java index 556d92015..3a506ef1f 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/type/DecoratedTypeMirror.java @@ -16,6 +16,7 @@ package com.webcohesion.enunciate.javac.decorations.type; import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecoration; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; @@ -38,6 +39,12 @@ public DecoratedTypeMirror(T delegate, DecoratedProcessingEnvironment env) { this.delegate = delegate; this.env = env; + + if (this.env.getTypeMirrorDecorations() != null) { + for (TypeMirrorDecoration decoration : this.env.getTypeMirrorDecorations()) { + decoration.applyTo(this); + } + } } @Override diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java new file mode 100644 index 000000000..bab68a56e --- /dev/null +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java @@ -0,0 +1,27 @@ +package com.webcohesion.enunciate.modules.lombok; + +import com.webcohesion.enunciate.javac.decorations.ElementDecoration; +import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; +import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; + +import javax.lang.model.element.TypeElement; +import javax.lang.model.util.SimpleElementVisitor6; + +/** + * @author Ryan Heaton + */ +public class LombokDecoration extends SimpleElementVisitor6 implements ElementDecoration { + + @Override + public void applyTo(DecoratedElement e) { + e.accept(this, null); + } + + @Override + public Void visitType(TypeElement e, Void aVoid) { + DecoratedTypeElement typeElement = (DecoratedTypeElement) e; + //todo: modify the element as needed. + return null; + } + +} diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokModule.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokModule.java index c2d262f99..56e9d6f42 100644 --- a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokModule.java +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokModule.java @@ -1,13 +1,14 @@ package com.webcohesion.enunciate.modules.lombok; import com.webcohesion.enunciate.EnunciateContext; -import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import com.webcohesion.enunciate.javac.decorations.AnnotationMirrorDecoration; +import com.webcohesion.enunciate.javac.decorations.ElementDecoration; +import com.webcohesion.enunciate.javac.decorations.TypeMirrorDecoration; import com.webcohesion.enunciate.module.BasicEnunicateModule; import com.webcohesion.enunciate.module.ContextModifyingModule; -import lombok.Data; -import javax.lang.model.element.Element; -import java.util.Set; +import java.util.Collections; +import java.util.List; /** * @author Ryan Heaton @@ -19,16 +20,24 @@ public String getName() { return "lombok"; } + @Override + public List getElementDecorations() { + return Collections.singletonList(new LombokDecoration()); + } + + @Override + public List getTypeMirrorDecorations() { + return Collections.emptyList(); + } + + @Override + public List getAnnotationMirrorDecorations() { + return Collections.emptyList(); + } + @Override public void call(EnunciateContext context) { - Set apiElements = context.getApiElements(); - for (Element apiElement : apiElements) { - if (apiElement instanceof DecoratedTypeElement && apiElement.getAnnotation(Data.class) != null) { - DecoratedTypeElement typeElement = (DecoratedTypeElement) apiElement; - //todo: modify the element as needed - - } - } + //no-op. } } From efd8012565e92ba6e438b4c8597473b28a942902 Mon Sep 17 00:00:00 2001 From: Ryan Heaton Date: Mon, 26 Sep 2016 13:42:59 -0600 Subject: [PATCH 04/12] bug in 'accept' method of decorated element: infinite loop --- .../javac/decorations/element/DecoratedElement.java | 2 +- .../enunciate/modules/lombok/LombokDecoration.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java index 07bfcfcf4..3604f2671 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java @@ -242,7 +242,7 @@ public List getEnclosedElements() { @Override public R accept(ElementVisitor v, P p) { - return v.visit(this, p); + return v.visitUnknown(this, p); } //Inherited. diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java index bab68a56e..fa6d9053b 100644 --- a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java @@ -4,6 +4,7 @@ import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.util.SimpleElementVisitor6; @@ -24,4 +25,9 @@ public Void visitType(TypeElement e, Void aVoid) { return null; } + @Override + public Void visitUnknown(Element e, Void aVoid) { + //no-op + return null; + } } From 8c9c915e3c3484295bbbc83de649bd90339315f1 Mon Sep 17 00:00:00 2001 From: Ryan Heaton Date: Thu, 22 Sep 2016 15:16:28 -0600 Subject: [PATCH 05/12] support for pluggable decoration modules --- .../EnunciateAnnotationProcessor.java | 1 + examples/jackson2-api-lombok/build.xml | 40 ++++ examples/jackson2-api-lombok/enunciate.xml | 7 + examples/jackson2-api-lombok/pom.xml | 101 ++++++++++ .../genealogy/data/Assertion.java | 63 ++++++ .../jaxrsjackson/genealogy/data/Event.java | 89 +++++++++ .../genealogy/data/EventType.java | 50 +++++ .../jaxrsjackson/genealogy/data/Fact.java | 100 ++++++++++ .../jaxrsjackson/genealogy/data/FactType.java | 49 +++++ .../jaxrsjackson/genealogy/data/Gender.java | 44 +++++ .../genealogy/data/GenderType.java | 34 ++++ .../jaxrsjackson/genealogy/data/MapThing.java | 24 +++ .../jaxrsjackson/genealogy/data/Name.java | 53 +++++ .../genealogy/data/OccurringAssertion.java | 79 ++++++++ .../jaxrsjackson/genealogy/data/Person.java | 183 ++++++++++++++++++ .../genealogy/data/Relationship.java | 97 ++++++++++ .../genealogy/data/api/PersonService.java | 43 ++++ .../src/main/resources/log4j.xml | 32 +++ .../src/main/webapp/WEB-INF/web.xml | 21 ++ examples/pom.xml | 1 + .../decorations/element/DecoratedElement.java | 3 + .../element/DecoratedTypeElement.java | 14 +- .../modules/lombok/LombokDecoration.java | 12 +- .../modules/lombok/LombokMethodGenerator.java | 84 ++++++++ ...bokPropertyDecoratedExecutableElement.java | 120 ++++++++++++ 25 files changed, 1342 insertions(+), 2 deletions(-) create mode 100755 examples/jackson2-api-lombok/build.xml create mode 100644 examples/jackson2-api-lombok/enunciate.xml create mode 100644 examples/jackson2-api-lombok/pom.xml create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Assertion.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Event.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/EventType.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Fact.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/FactType.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Gender.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/GenderType.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/MapThing.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Name.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/OccurringAssertion.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Person.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Relationship.java create mode 100644 examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/api/PersonService.java create mode 100644 examples/jackson2-api-lombok/src/main/resources/log4j.xml create mode 100644 examples/jackson2-api-lombok/src/main/webapp/WEB-INF/web.xml create mode 100644 lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodGenerator.java create mode 100644 lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java diff --git a/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java b/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java index 3f7372af9..3bfe0a298 100644 --- a/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java +++ b/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java @@ -66,6 +66,7 @@ public synchronized void init(ProcessingEnvironment processingEnv) { //initialize the modules. for (EnunciateModule module : this.enunciate.getModules()) { + System.out.println("Init module " + module.getName()); module.init(this.context); if (module instanceof ContextModifyingModule) { diff --git a/examples/jackson2-api-lombok/build.xml b/examples/jackson2-api-lombok/build.xml new file mode 100755 index 000000000..affec0c3c --- /dev/null +++ b/examples/jackson2-api-lombok/build.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/jackson2-api-lombok/enunciate.xml b/examples/jackson2-api-lombok/enunciate.xml new file mode 100644 index 000000000..3d7fdbc8a --- /dev/null +++ b/examples/jackson2-api-lombok/enunciate.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/examples/jackson2-api-lombok/pom.xml b/examples/jackson2-api-lombok/pom.xml new file mode 100644 index 000000000..9fb1b3a83 --- /dev/null +++ b/examples/jackson2-api-lombok/pom.xml @@ -0,0 +1,101 @@ + + + 4.0.0 + + com.webcohesion.enunciate + enunciate-examples + 2.7.0-SNAPSHOT + + + enunciate-examples-jax-rs-jackson-lombok + Enunciate - Jackson 2 API Lombok Example + Enunciate Example: Jackson 2 API Lombok + war + + + + + com.webcohesion.enunciate + enunciate-maven-plugin + ${enunciate.version} + + + assemble + + assemble + + + + java-json-client + + + + + + + com.webcohesion.enunciate + enunciate-lombok + ${enunciate.version} + + + + + + maven-deploy-plugin + + true + + + + + + + + + com.webcohesion.enunciate + enunciate-maven-plugin + ${enunciate.version} + + + + + + + com.webcohesion.enunciate + enunciate-core-annotations + ${enunciate.version} + + + + com.sun.jersey + jersey-server + ${jersey1.version} + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + ${jackson2.version} + + + + javax.servlet + javax.servlet-api + + provided + + + + javax.validation + validation-api + + + + org.projectlombok + lombok + + + + + diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Assertion.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Assertion.java new file mode 100644 index 000000000..6f511e55f --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Assertion.java @@ -0,0 +1,63 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +/** + * An assertion of a piece of information, usually associated with a source. + * + * @author Ryan Heaton + */ +public abstract class Assertion { + + private String id; + private String note; + + /** + * The id of the assertion. + * + * @return The id of the assertion. + */ + public String getId() { + return id; + } + + /** + * The id of the assertion. + * + * @param id The id of the assertion. + */ + public void setId(String id) { + this.id = id; + } + + /** + * A note associated with this assertion. + * + * @return A note associated with this assertion. + */ + public String getNote() { + return note; + } + + /** + * A note associated with this assertion. + * + * @param note A note associated with this assertion. + */ + public void setNote(String note) { + this.note = note; + } +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Event.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Event.java new file mode 100644 index 000000000..7ab8fa7a6 --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Event.java @@ -0,0 +1,89 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * An event assertion. + * + * @author Ryan Heaton + */ +public class Event extends OccurringAssertion { + + private EventType type; + private String description; + private final List tags = new ArrayList(); + private String explanation; + + /** + * The type of this event. + * + * @return The type of this event. + */ + public EventType getType() { + return type; + } + + /** + * The type of this event. + * + * @param type The type of this event. + */ + public void setType(EventType type) { + this.type = type; + } + + /** + * A description of this event. + * + * @return A description of this event. + */ + @NotNull + public String getDescription() { + return description; + } + + /** + * A description of this event. + * + * @param description A description of this event. + */ + public void setDescription(String description) { + this.description = description; + } + + public String[] getTags() { + return tags.toArray(new String[tags.size()]); + } + + public void setTags(String tags[]) { + this.tags.clear(); + this.tags.addAll(Arrays.asList(tags)); + } + + public String getExplanation() { + return explanation; + } + + public void setExplanation(String explanation) { + this.explanation = explanation; + } + +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/EventType.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/EventType.java new file mode 100644 index 000000000..3547dcaf1 --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/EventType.java @@ -0,0 +1,50 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +/** + * Enumeration for event types. + * + * @author Ryan Heaton + */ +public enum EventType { + + /** + * Specifies a birth event. + */ + birth, + + /** + * Specifies a christening event. + */ + christening, + + /** + * Specifies a marriage event. + */ + marriage, + + /** + * Specifies a death event. + */ + death, + + /** + * Specifies a burial event. + */ + burial + +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Fact.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Fact.java new file mode 100644 index 000000000..b8feac571 --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Fact.java @@ -0,0 +1,100 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +/** + * A generic fact assertion. + * + * @author Ryan Heaton + */ +public class Fact extends OccurringAssertion { + + private FactType type; + private String value; + private String description; + private String[] tags; + private String explanation; + + /** + * The fact type. + * + * @return The fact type. + */ + public FactType getType() { + return type; + } + + /** + * The fact type. + * + * @param type The fact type. + */ + public void setType(FactType type) { + this.type = type; + } + + /** + * The value of the fact. + * + * @return The value of the fact. + */ + public String getValue() { + return value; + } + + /** + * The value of the fact. + * + * @param value The value of the fact. + */ + public void setValue(String value) { + this.value = value; + } + + /** + * A description of the fact. + * + * @return A description of the fact. + */ + public String getDescription() { + return description; + } + + /** + * A description of the fact. + * + * @param description A description of the fact. + */ + public void setDescription(String description) { + this.description = description; + } + + public String[] getTags() { + return tags; + } + + public void setTags(String[] tags) { + this.tags = tags; + } + + public String getExplanation() { + return explanation; + } + + public void setExplanation(String explanation) { + this.explanation = explanation; + } +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/FactType.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/FactType.java new file mode 100644 index 000000000..e481b097d --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/FactType.java @@ -0,0 +1,49 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +/** + * The set of fact types. + * + * @author Ryan Heaton + */ +public enum FactType { + + /** + * somebody's occupation. + */ + occupation, + + /** + * somebody's possessions. + */ + possessions, + + /** + * somebody's race. + */ + race, + + /** + * somebody's nation of origin. + */ + nation_of_origin, + + /** + * somebody's physical description. + */ + physical_description +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Gender.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Gender.java new file mode 100644 index 000000000..bb5c11ced --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Gender.java @@ -0,0 +1,44 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +/** + * A gender assertion. + * + * @author Ryan Heaton + */ +public class Gender extends Assertion { + + private GenderType type; + + /** + * The type of gender. + * + * @return The type of gender. + */ + public GenderType getType() { + return type; + } + + /** + * The type of gender. + * + * @param type The type of gender. + */ + public void setType(GenderType type) { + this.type = type; + } +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/GenderType.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/GenderType.java new file mode 100644 index 000000000..f98ed9db5 --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/GenderType.java @@ -0,0 +1,34 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +/** + * The types of gender. + * + * @author Ryan Heaton + */ +public enum GenderType { + + /** + * Male gender. + */ + MALE, + + /** + * Female gender. + */ + FEMALE +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/MapThing.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/MapThing.java new file mode 100644 index 000000000..490c9c985 --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/MapThing.java @@ -0,0 +1,24 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +import java.util.HashMap; + +/** + * @author Ryan Heaton + */ +public class MapThing extends HashMap { +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Name.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Name.java new file mode 100644 index 000000000..2f42cfd27 --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Name.java @@ -0,0 +1,53 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +/** + * A name assertion. An example name is Yamada Tarō (山田太郎). + * + * @author Ryan Heaton + */ +public class Name extends Assertion { + + private String value; + private Character middleInitial; + + /** + * The text value of the name. + * + * @return The text value of the name. + */ + public String getValue() { + return value; + } + + /** + * The text value of the name. + * + * @param value The text value of the name. + */ + public void setValue(String value) { + this.value = value; + } + + public Character getMiddleInitial() { + return middleInitial; + } + + public void setMiddleInitial(Character middleInitial) { + this.middleInitial = middleInitial; + } +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/OccurringAssertion.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/OccurringAssertion.java new file mode 100644 index 000000000..22b4e8bab --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/OccurringAssertion.java @@ -0,0 +1,79 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +import java.util.Date; + +/** + * An assertion that occurs at some point in time. + * + * @author Ryan Heaton + */ +public abstract class OccurringAssertion extends Assertion { + + private Date date; + private String place; + + /** + * The date of the occurrence. + * + * @return The date of the occurrence. + */ + public Date getDate() { + return date; + } + + /** + * The date of the occurrence. + * + * @param date The date of the occurrence. + */ + public void setDate(Date date) { + this.date = date; + } + + /** + * The place of the occurrence. + * + * @return The place of the occurrence. + */ + public String getPlace() { + return place; + } + + /** + * The place of the occurrence. + * + * @param place The place of the occurrence. + */ + public void setPlace(String place) { + this.place = place; + } + + /** + * The explanation for the assertion. + * + * @return The explanation for the assertion. + */ + public abstract String getExplanation(); + + /** + * The explanation for the assertion. + * + * @param explanation The explanation for the assertion. + */ + public abstract void setExplanation(String explanation); +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Person.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Person.java new file mode 100644 index 000000000..b2e4833c5 --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Person.java @@ -0,0 +1,183 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.webcohesion.enunciate.metadata.Label; + +import java.util.Collection; +import java.util.Map; + +/** + * A person. The central data in genealogical information. + * + * @author Ryan Heaton + */ +@JsonSerialize +public class Person { + + private String id; + private Gender gender; + private Collection names; + private Collection events; + private Collection facts; + private Collection relationships; + private Map eventDescriptions; + private Assertion primaryAssertion; + private State state; + private MapThing mapThing; + + @Label ("PersonState") + enum State { + + old, + + young + + } + + /** + * The person id. + * + * @return The person id. + */ + public String getId() { + return id; + } + + /** + * The person id. + * + * @param id The person id. + */ + public void setId(String id) { + this.id = id; + } + + /** + * The gender of a person. + * + * @return The gender of a person. + */ + public Gender getGender() { + return gender; + } + + /** + * The gender of a person. + * + * @param gender The gender of a person. + */ + public void setGender(Gender gender) { + this.gender = gender; + } + + public Assertion getPrimaryAssertion() { + return primaryAssertion; + } + + public void setPrimaryAssertion(Assertion primaryAssertion) { + this.primaryAssertion = primaryAssertion; + } + + /** + * The names of the person. + * + * @return The names of the person. + */ + public Collection getNames() { + return names; + } + + /** + * The names of the person. + * + * @param names The names of the person. + */ + public void setNames(Collection names) { + this.names = names; + } + + /** + * The events associated with a person. + * + * @return The events associated with a person. + */ + public Collection getEvents() { + return events; + } + + /** + * The events associated with a person. + * + * @param events The events associated with a person. + */ + public void setEvents(Collection events) { + this.events = events; + } + + /** + * The facts about a person. + * + * @return The facts about a person. + */ + public Collection getFacts() { + return facts; + } + + /** + * The facts about a person. + * + * @param facts The facts about a person. + */ + public void setFacts(Collection facts) { + this.facts = facts; + } + + /** + * The relationships of a person. + * + * @return The relationships of a person. + */ + public Collection getRelationships() { + return relationships; + } + + /** + * The relationships of a person. + * + * @param relationships The relationships of a person. + */ + public void setRelationships(Collection relationships) { + this.relationships = relationships; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + public MapThing getMapThing() { + return mapThing; + } + + public void setMapThing(MapThing mapThing) { + this.mapThing = mapThing; + } +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Relationship.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Relationship.java new file mode 100644 index 000000000..35de5311d --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Relationship.java @@ -0,0 +1,97 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; + +/** + * A relationship between two people. + * + * @author Ryan Heaton + */ +public class Relationship extends Assertion { + + private String id; + private Name sourcePersonName; + private Name targetPersonName; + private State state; + + enum State { + connected, + + disconnected + } + + /** + * The id of the relationship. + * + * @return The id of the relationship. + */ + public String getId() { + return id; + } + + /** + * The id of the relationship. + * + * @param id The id of the relationship. + */ + public void setId(String id) { + this.id = id; + } + + /** + * The name of the source person. + * + * @return The name of the source person. + */ + public Name getSourcePersonName() { + return sourcePersonName; + } + + /** + * The name of the source person. + * + * @param sourcePersonName The name of the source person. + */ + public void setSourcePersonName(Name sourcePersonName) { + this.sourcePersonName = sourcePersonName; + } + + /** + * The name of the target person. + * + * @return The name of the target person. + */ + public Name getTargetPersonName() { + return targetPersonName; + } + + /** + * The name of the target person. + * + * @param targetPersonName The name of the target person. + */ + public void setTargetPersonName(Name targetPersonName) { + this.targetPersonName = targetPersonName; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } +} diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/api/PersonService.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/api/PersonService.java new file mode 100644 index 000000000..c73e8567d --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/api/PersonService.java @@ -0,0 +1,43 @@ +/** + * Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data.api; + +import com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data.Person; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +/** + * @author Ryan Heaton + */ +@Path("/persons") +public class PersonService { + + @GET + @Path("{id}") + public Person getPerson(@PathParam("id") String id) { + return new Person(); + } + + @GET + @Path("/multiple/{ids}") + public Response getMultiplePersons(@PathParam("ids") String ids) { + return Response.ok().build(); + } + +} diff --git a/examples/jackson2-api-lombok/src/main/resources/log4j.xml b/examples/jackson2-api-lombok/src/main/resources/log4j.xml new file mode 100644 index 000000000..6148ac80f --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/resources/log4j.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/jackson2-api-lombok/src/main/webapp/WEB-INF/web.xml b/examples/jackson2-api-lombok/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..443e63824 --- /dev/null +++ b/examples/jackson2-api-lombok/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,21 @@ + + + + + diff --git a/examples/pom.xml b/examples/pom.xml index 6a9dabb35..726f935cb 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -15,6 +15,7 @@ full-api-edge-cases jackson2-api + jackson2-api-lombok jersey-storage jersey-storage-spring jboss diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java index 3604f2671..c4041331b 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java @@ -243,6 +243,9 @@ public List getEnclosedElements() { @Override public R accept(ElementVisitor v, P p) { return v.visitUnknown(this, p); +// throw new IllegalArgumentException("KATARAKTA"); +// System.out.println("Accept visitor " + v + " and property " + p + " on this " + this.getClass()); +// return v.visit(this, p); } //Inherited. diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java index 2ec96f254..9d0edabc2 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedTypeElement.java @@ -92,7 +92,7 @@ public List getInterfaces() { return this.interfaces; } - public List getMethods() { + public List getMethods() { if (this.methods == null) { this.methods = ElementDecorator.decorate(ElementFilter.methodsIn(this.delegate.getEnclosedElements()), this.env); } @@ -100,6 +100,18 @@ public List getMethods() { return this.methods; } + public List getFields() { + List fields = new ArrayList(); + List allFields = ElementFilter.fieldsIn(this.delegate.getEnclosedElements()); + for (VariableElement field : allFields) { + if (field.getKind() == ElementKind.FIELD && !(field.getModifiers().contains(Modifier.STATIC))) { + fields.add(field); + } + } + + return fields; + } + public List getConstructors() { if (this.constructors == null) { this.constructors = ElementDecorator.decorate(ElementFilter.constructorsIn(this.delegate.getEnclosedElements()), this.env); diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java index fa6d9053b..b028a4f5e 100644 --- a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java @@ -15,13 +15,18 @@ public class LombokDecoration extends SimpleElementVisitor6 implemen @Override public void applyTo(DecoratedElement e) { + System.out.println("Lombok decoration applied to " + e); e.accept(this, null); } + @Override public Void visitType(TypeElement e, Void aVoid) { + System.out.println("Lombok visitType " + e); DecoratedTypeElement typeElement = (DecoratedTypeElement) e; - //todo: modify the element as needed. + LombokMethodGenerator lombokMethodGenerator = new LombokMethodGenerator(typeElement, null); + lombokMethodGenerator.generateLombokGettersAndSetters(); + System.out.println("Lombok visitType " + e + " visited"); return null; } @@ -30,4 +35,9 @@ public Void visitUnknown(Element e, Void aVoid) { //no-op return null; } + + + + + } diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodGenerator.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodGenerator.java new file mode 100644 index 000000000..2c9eea11d --- /dev/null +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodGenerator.java @@ -0,0 +1,84 @@ +package com.webcohesion.enunciate.modules.lombok; + +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement; +import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.VariableElement; +import java.util.List; + +/** + * @author Tomasz Kalkosiński + */ +public class LombokMethodGenerator { + + private DecoratedTypeElement decoratedTypeElement; + private DecoratedProcessingEnvironment env; + + public LombokMethodGenerator(DecoratedTypeElement decoratedTypeElement, DecoratedProcessingEnvironment env) { + this.decoratedTypeElement = decoratedTypeElement; + this.env = env; + } + + public void generateLombokGettersAndSetters() { + List fields = decoratedTypeElement.getFields(); + for (VariableElement field : fields) { + System.out.println("Field " + field.getSimpleName() + " of class " + field.getClass().getSimpleName()); + +// DecoratedVariableElement decoratedVariableElement = (DecoratedVariableElement) field; + if (shouldGenerateGetter(field)) { + System.out.println("Adding getter to " + decoratedTypeElement + " " + System.identityHashCode(decoratedTypeElement) + " for field " + field); + decoratedTypeElement.getMethods().add(new LombokPropertyDecoratedExecutableElement(field, env, true)); + } + if (shouldGenerateSetter(field)) { + System.out.println("Adding setter to " + decoratedTypeElement + " " + System.identityHashCode(decoratedTypeElement) + " for field " + field); + decoratedTypeElement.getMethods().add(new LombokPropertyDecoratedExecutableElement(field, env, false)); + } + } + } + + private boolean shouldGenerateGetter(Element field) { + String fieldSimpleName = field.getSimpleName().toString(); + for (ExecutableElement method : decoratedTypeElement.getMethods()) { + DecoratedExecutableElement decoratedMethod = (DecoratedExecutableElement) method; + if (decoratedMethod.getPropertyName() != null && decoratedMethod.getPropertyName().equals(fieldSimpleName) && decoratedMethod.isGetter()) { + return false; + } + } + + if (field.getAnnotation(Getter.class) != null) { + return true; + } + + if (decoratedTypeElement.getAnnotation(Data.class) != null) { + return true; + } + + return false; + } + + private boolean shouldGenerateSetter(Element field) { + String fieldSimpleName = field.getSimpleName().toString(); + for (ExecutableElement method : decoratedTypeElement.getMethods()) { + DecoratedExecutableElement decoratedMethod = (DecoratedExecutableElement) method; + if (decoratedMethod.getPropertyName() != null && decoratedMethod.getPropertyName().equals(fieldSimpleName) && decoratedMethod.isSetter()) { + return false; + } + } + + if (field.getAnnotation(Setter.class) != null) { + return true; + } + + if (decoratedTypeElement.getAnnotation(Data.class) != null) { + return true; + } + + return false; + } +} \ No newline at end of file diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java new file mode 100644 index 000000000..113634546 --- /dev/null +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java @@ -0,0 +1,120 @@ +package com.webcohesion.enunciate.modules.lombok; + +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement; + +import javax.lang.model.element.*; +import javax.lang.model.type.TypeMirror; +import java.lang.annotation.Annotation; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** + * @author Tomasz Kalkosiński + */ +public class LombokPropertyDecoratedExecutableElement extends DecoratedExecutableElement implements ExecutableElement { + + private VariableElement variableElement; + private boolean getter; + + public LombokPropertyDecoratedExecutableElement(VariableElement variableElement, DecoratedProcessingEnvironment env, boolean getter) { + super(null, env); + this.variableElement = variableElement; + this.getter = getter; + } + + @Override + public List getTypeParameters() { + return null; + } + + @Override + public TypeMirror getReturnType() { + return getter ? variableElement.asType() : null; + } + + @Override + public List getParameters() { + return getter ? Collections.emptyList() : Collections.singletonList(variableElement); + } + + @Override + public boolean isVarArgs() { + return false; + } + + @Override + public List getThrownTypes() { + return null; + } + + @Override + public AnnotationValue getDefaultValue() { + return null; + } + + @Override + public TypeMirror asType() { + return variableElement.asType(); + } + + @Override + public ElementKind getKind() { + return variableElement.getKind(); + } + + @Override + public List getAnnotationMirrors() { + return variableElement.getAnnotationMirrors(); + } + + @Override + public A getAnnotation(Class annotationType) { + return variableElement.getAnnotation(annotationType); + } + + @Override + public Set getModifiers() { + return Collections.singleton(Modifier.PUBLIC); + } + + /** + * This probably should return a Name with "get"/"set"/"is" prefix but it's hard to put a new Name into SharedNameTable. + * @returns variableElement#getSimpleName() until it creates some blocker issue that needs to improve it + */ + @Override + public Name getSimpleName() { + return variableElement.getSimpleName(); + } + + @Override + public Element getEnclosingElement() { + return variableElement.getEnclosingElement(); + } + + @Override + public List getEnclosedElements() { + return variableElement.getEnclosedElements(); + } + + @Override + public String getPropertyName() { + return variableElement.getSimpleName().toString(); + } + + @Override + public String toString() { + return variableElement.toString(); + } + + @Override + public boolean isGetter() { + return getter; + } + + @Override + public boolean isSetter() { + return !getter; + } +} \ No newline at end of file From 83662ff395c7590abef112a0ecee910d905ad0f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kalkosi=C5=84ski?= Date: Tue, 27 Sep 2016 23:04:54 +0200 Subject: [PATCH 06/12] Before adding env to visitor --- .../jaxrsjackson/genealogy/data/Fact.java | 73 +------------------ .../decorations/element/DecoratedElement.java | 3 +- 2 files changed, 5 insertions(+), 71 deletions(-) diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Fact.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Fact.java index b8feac571..8623fac6d 100644 --- a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Fact.java +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Fact.java @@ -15,11 +15,14 @@ */ package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; +import lombok.Data; + /** * A generic fact assertion. * * @author Ryan Heaton */ +@Data public class Fact extends OccurringAssertion { private FactType type; @@ -27,74 +30,4 @@ public class Fact extends OccurringAssertion { private String description; private String[] tags; private String explanation; - - /** - * The fact type. - * - * @return The fact type. - */ - public FactType getType() { - return type; - } - - /** - * The fact type. - * - * @param type The fact type. - */ - public void setType(FactType type) { - this.type = type; - } - - /** - * The value of the fact. - * - * @return The value of the fact. - */ - public String getValue() { - return value; - } - - /** - * The value of the fact. - * - * @param value The value of the fact. - */ - public void setValue(String value) { - this.value = value; - } - - /** - * A description of the fact. - * - * @return A description of the fact. - */ - public String getDescription() { - return description; - } - - /** - * A description of the fact. - * - * @param description A description of the fact. - */ - public void setDescription(String description) { - this.description = description; - } - - public String[] getTags() { - return tags; - } - - public void setTags(String[] tags) { - this.tags = tags; - } - - public String getExplanation() { - return explanation; - } - - public void setExplanation(String explanation) { - this.explanation = explanation; - } } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java index c4041331b..5486b7d8c 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java @@ -45,7 +45,8 @@ public DecoratedElement(E delegate, DecoratedProcessingEnvironment env) { this.delegate = delegate; this.env = env; - if (this.env.getElementDecorations() != null) { + //env can be null for decorations + if (this.env != null && this.env.getElementDecorations() != null) { for (ElementDecoration elementDecoration : this.env.getElementDecorations()) { elementDecoration.applyTo(this); } From 77d38c3e810ba17ca41a162ea3c771ab8003a825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kalkosi=C5=84ski?= Date: Wed, 28 Sep 2016 15:20:17 +0200 Subject: [PATCH 07/12] More and more NPEs --- .../modules/jackson/model/TypeDefinition.java | 6 ++++-- .../javac/decorations/DecoratedElements.java | 9 ++++++++- .../javac/decorations/ElementDecoration.java | 2 +- .../decorations/element/DecoratedElement.java | 11 +++++++++-- .../decorations/element/PropertyElement.java | 14 +++++++++----- .../modules/lombok/LombokDecoration.java | 16 ++++++++-------- .../modules/lombok/LombokMethodSymbol.java | 9 +++++++++ ...LombokPropertyDecoratedExecutableElement.java | 2 +- 8 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodSymbol.java diff --git a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/TypeDefinition.java b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/TypeDefinition.java index 77c9fdb34..5acf0b1d8 100644 --- a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/TypeDefinition.java +++ b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/TypeDefinition.java @@ -102,6 +102,8 @@ else if (isWildcardProperty(accessor)) { //its an property accessor. if (accessor instanceof PropertyElement) { + System.out.println("Accessor is " + accessor + " with getter " + ((PropertyElement) accessor).getGetter() + " with setter " + ((PropertyElement) accessor).getSetter()); + //if the accessor is a property and either the getter or setter overrides ANY method of ANY superclass, exclude it. if (overridesAnother(((PropertyElement) accessor).getGetter()) || overridesAnother(((PropertyElement) accessor).getSetter())) { continue; @@ -182,7 +184,7 @@ protected void aggregatePotentialAccessors(List fields, List implements Element { @@ -48,7 +50,7 @@ public DecoratedElement(E delegate, DecoratedProcessingEnvironment env) { //env can be null for decorations if (this.env != null && this.env.getElementDecorations() != null) { for (ElementDecoration elementDecoration : this.env.getElementDecorations()) { - elementDecoration.applyTo(this); + elementDecoration.applyTo(this, this.env); } } } @@ -226,6 +228,11 @@ public ElementKind getKind() { @Override public Element getEnclosingElement() { if (this.enclosingElement == null) { + if (this.delegate == null) { + System.out.println("Delegate is null for " + this + " of class " + this.getClass()); + return null; + + } this.enclosingElement = ElementDecorator.decorate(delegate.getEnclosingElement(), env); } @@ -292,7 +299,7 @@ public boolean equals(Object obj) { //Inherited. public String toString() { - return this.delegate.toString(); + return this.delegate == null ? null : this.delegate.toString(); } } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/PropertyElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/PropertyElement.java index 690bc223e..e25f87d86 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/PropertyElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/PropertyElement.java @@ -16,10 +16,7 @@ package com.webcohesion.enunciate.javac.decorations.element; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.ElementVisitor; -import javax.lang.model.element.Name; -import javax.lang.model.element.VariableElement; +import javax.lang.model.element.*; import javax.lang.model.type.TypeMirror; import java.lang.annotation.Annotation; import java.util.*; @@ -47,6 +44,13 @@ public class PropertyElement extends DecoratedExecutableElement { public PropertyElement(DecoratedExecutableElement getter, DecoratedExecutableElement setter, ProcessingEnvironment env) { super(getter == null ? setter : getter); + DecoratedExecutableElement wtf = getter == null ? setter : getter; + if (wtf.env == null) { + System.out.println("Null env for " + wtf.getClass() + wtf); + throw new IllegalArgumentException(); + } + + this.getter = getter; this.setter = setter; this.propertyName = getter != null ? getter.getPropertyName() : setter.getPropertyName(); @@ -75,7 +79,7 @@ else if (!env.getTypeUtils().isSameType(propertyType, setterType)) { if (propertyType == null) { throw new IllegalStateException("Unable to determine property type for property" + this.propertyName + "."); } - + this.propertyType = propertyType; } diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java index b028a4f5e..799b8db03 100644 --- a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java @@ -1,5 +1,6 @@ package com.webcohesion.enunciate.modules.lombok; +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; import com.webcohesion.enunciate.javac.decorations.ElementDecoration; import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement; @@ -11,27 +12,26 @@ /** * @author Ryan Heaton */ -public class LombokDecoration extends SimpleElementVisitor6 implements ElementDecoration { +public class LombokDecoration extends SimpleElementVisitor6 implements ElementDecoration { @Override - public void applyTo(DecoratedElement e) { - System.out.println("Lombok decoration applied to " + e); - e.accept(this, null); + public void applyTo(DecoratedElement e, DecoratedProcessingEnvironment env) { +// System.out.println("Lombok decoration applied to " + e); + e.accept(this, env); } - @Override - public Void visitType(TypeElement e, Void aVoid) { + public Void visitType(TypeElement e, DecoratedProcessingEnvironment env) { System.out.println("Lombok visitType " + e); DecoratedTypeElement typeElement = (DecoratedTypeElement) e; - LombokMethodGenerator lombokMethodGenerator = new LombokMethodGenerator(typeElement, null); + LombokMethodGenerator lombokMethodGenerator = new LombokMethodGenerator(typeElement, env); lombokMethodGenerator.generateLombokGettersAndSetters(); System.out.println("Lombok visitType " + e + " visited"); return null; } @Override - public Void visitUnknown(Element e, Void aVoid) { + public Void visitUnknown(Element e, DecoratedProcessingEnvironment env) { //no-op return null; } diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodSymbol.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodSymbol.java new file mode 100644 index 000000000..d1459bbc3 --- /dev/null +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodSymbol.java @@ -0,0 +1,9 @@ +package com.webcohesion.enunciate.modules.lombok; + +import com.sun.tools.javac.code.Symbol; + +public class LombokMethodSymbol extends Symbol.MethodSymbol { + public LombokMethodSymbol(VarSymbol varSymbol) { + super(varSymbol.flags(), varSymbol.name, varSymbol.type, varSymbol.owner); + } +} diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java index 113634546..6d15823fc 100644 --- a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java @@ -105,7 +105,7 @@ public String getPropertyName() { @Override public String toString() { - return variableElement.toString(); + return variableElement == null ? null : variableElement.toString(); } @Override From 25c5298b6586f1398ead5c480d68e2a0103c2279 Mon Sep 17 00:00:00 2001 From: Ryan Heaton Date: Wed, 28 Sep 2016 15:24:19 -0600 Subject: [PATCH 08/12] support for handling adapted elements --- .../EnunciateAnnotationProcessor.java | 1 - .../module/BasicEnunicateModule.java | 7 +- .../csharp_client/CSharpXMLClientModule.java | 8 +- .../modules/jackson/model/TypeDefinition.java | 2 - .../javac/decorations/DecoratedElements.java | 55 ++++-- .../DecoratedProcessingEnvironment.java | 5 + .../decorations/adaptors/ElementAdaptor.java | 28 +++ .../adaptors/ExecutableElementAdaptor.java | 14 ++ .../adaptors/PackageElementAdaptor.java | 9 + .../adaptors/TypeElementAdaptor.java | 19 ++ .../adaptors/TypeParameterElementAdaptor.java | 9 + .../adaptors/VariableElementAdaptor.java | 9 + .../decorations/element/DecoratedElement.java | 12 +- .../decorations/element/ElementUtils.java | 4 + .../decorations/element/PropertyElement.java | 18 +- .../modules/lombok/LombokDecoration.java | 3 - .../modules/lombok/LombokGeneratedGetter.java | 187 ++++++++++++++++++ .../modules/lombok/LombokGeneratedSetter.java | 187 ++++++++++++++++++ .../modules/lombok/LombokMethodGenerator.java | 9 +- .../modules/lombok/LombokMethodSymbol.java | 9 - ...bokPropertyDecoratedExecutableElement.java | 120 ----------- 21 files changed, 527 insertions(+), 188 deletions(-) create mode 100644 javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/ElementAdaptor.java create mode 100644 javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/ExecutableElementAdaptor.java create mode 100644 javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/PackageElementAdaptor.java create mode 100644 javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/TypeElementAdaptor.java create mode 100644 javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/TypeParameterElementAdaptor.java create mode 100644 javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/VariableElementAdaptor.java create mode 100644 lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokGeneratedGetter.java create mode 100644 lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokGeneratedSetter.java delete mode 100644 lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodSymbol.java delete mode 100644 lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java diff --git a/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java b/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java index 3bfe0a298..3f7372af9 100644 --- a/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java +++ b/core/src/main/java/com/webcohesion/enunciate/EnunciateAnnotationProcessor.java @@ -66,7 +66,6 @@ public synchronized void init(ProcessingEnvironment processingEnv) { //initialize the modules. for (EnunciateModule module : this.enunciate.getModules()) { - System.out.println("Init module " + module.getName()); module.init(this.context); if (module instanceof ContextModifyingModule) { diff --git a/core/src/main/java/com/webcohesion/enunciate/module/BasicEnunicateModule.java b/core/src/main/java/com/webcohesion/enunciate/module/BasicEnunicateModule.java index de9e56785..996b76916 100644 --- a/core/src/main/java/com/webcohesion/enunciate/module/BasicEnunicateModule.java +++ b/core/src/main/java/com/webcohesion/enunciate/module/BasicEnunicateModule.java @@ -17,6 +17,7 @@ import com.webcohesion.enunciate.Enunciate; import com.webcohesion.enunciate.EnunciateContext; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; import org.apache.commons.configuration.HierarchicalConfiguration; import javax.lang.model.element.ElementKind; @@ -94,11 +95,7 @@ protected String positionOf(javax.lang.model.element.Element element) { } //capitalize it. - return capitalize(position.toString()); - } - - protected String capitalize(String position) { - return Character.toUpperCase(position.charAt(0)) + position.substring(1); + return ElementUtils.capitalize(position.toString()); } protected String descriptionOf(javax.lang.model.element.Element element) { diff --git a/csharp-xml-client/src/main/java/com/webcohesion/enunciate/modules/csharp_client/CSharpXMLClientModule.java b/csharp-xml-client/src/main/java/com/webcohesion/enunciate/modules/csharp_client/CSharpXMLClientModule.java index 5163cbe73..cc4cc584e 100644 --- a/csharp-xml-client/src/main/java/com/webcohesion/enunciate/modules/csharp_client/CSharpXMLClientModule.java +++ b/csharp-xml-client/src/main/java/com/webcohesion/enunciate/modules/csharp_client/CSharpXMLClientModule.java @@ -234,7 +234,7 @@ else if (webParam.getMode() != javax.jws.WebParam.Mode.IN) { usesUnmappableElements = true; } - if (capitalize(webMethod.getClientSimpleName()).equals(ei.getClientSimpleName())) { + if (ElementUtils.capitalize(webMethod.getClientSimpleName()).equals(ei.getClientSimpleName())) { warn("%s: C# can't handle methods that are of the same name as their containing class. Either rename the method, or use the @org.codehaus.enunciate.ClientName annotation to rename the method (or type) on the client-side.", positionOf(webMethod)); usesUnmappableElements = true; } @@ -246,21 +246,21 @@ else if (webParam.getMode() != javax.jws.WebParam.Mode.IN) { for (SchemaInfo schemaInfo : this.jaxbModule.getJaxbContext().getSchemas().values()) { for (TypeDefinition complexType : schemaInfo.getTypeDefinitions()) { for (Attribute attribute : complexType.getAttributes()) { - if (capitalize(attribute.getClientSimpleName()).equals(complexType.getClientSimpleName())) { + if (ElementUtils.capitalize(attribute.getClientSimpleName()).equals(complexType.getClientSimpleName())) { warn("%s: C# can't handle properties/fields that are of the same name as their containing class. Either rename the property/field, or use the @com.webcohesion.enunciate.metadata.ClientName annotation to rename the property/field on the client-side.", positionOf(attribute)); usesUnmappableElements = true; } } if (complexType.getValue() != null) { - if (capitalize(complexType.getValue().getClientSimpleName()).equals(complexType.getClientSimpleName())) { + if (ElementUtils.capitalize(complexType.getValue().getClientSimpleName()).equals(complexType.getClientSimpleName())) { warn("%s: C# can't handle properties/fields that are of the same name as their containing class. Either rename the property/field, or use the @com.webcohesion.enunciate.metadata.ClientName annotation to rename the property/field on the client-side.", positionOf(complexType.getValue())); usesUnmappableElements = true; } } for (Element element : complexType.getElements()) { - if (capitalize(element.getClientSimpleName()).equals(complexType.getClientSimpleName())) { + if (ElementUtils.capitalize(element.getClientSimpleName()).equals(complexType.getClientSimpleName())) { warn("%s: C# can't handle properties/fields that are of the same name as their containing class. Either rename the property/field, or use the @com.webcohesion.enunciate.metadata.ClientName annotation to rename the property/field on the client-side.", positionOf(element)); usesUnmappableElements = true; } diff --git a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/TypeDefinition.java b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/TypeDefinition.java index 5acf0b1d8..a1e0aab9c 100644 --- a/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/TypeDefinition.java +++ b/jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/TypeDefinition.java @@ -102,8 +102,6 @@ else if (isWildcardProperty(accessor)) { //its an property accessor. if (accessor instanceof PropertyElement) { - System.out.println("Accessor is " + accessor + " with getter " + ((PropertyElement) accessor).getGetter() + " with setter " + ((PropertyElement) accessor).getSetter()); - //if the accessor is a property and either the getter or setter overrides ANY method of ANY superclass, exclude it. if (overridesAnother(((PropertyElement) accessor).getGetter()) || overridesAnother(((PropertyElement) accessor).getSetter())) { continue; diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java index 9c5585123..64fe9807b 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedElements.java @@ -15,6 +15,9 @@ */ package com.webcohesion.enunciate.javac.decorations; +import com.webcohesion.enunciate.javac.decorations.adaptors.ElementAdaptor; +import com.webcohesion.enunciate.javac.decorations.adaptors.ExecutableElementAdaptor; +import com.webcohesion.enunciate.javac.decorations.adaptors.TypeElementAdaptor; import com.webcohesion.enunciate.javac.decorations.element.DecoratedAnnotationMirror; import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; import com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement; @@ -70,7 +73,14 @@ public String getDocComment(Element e) { e = ((DecoratedElement) e).getDelegate(); } - String docComment = delegate.getDocComment(e); + String docComment; + if (e instanceof ElementAdaptor) { + docComment = ((ElementAdaptor) e).getDocComment(); + } + else { + docComment = delegate.getDocComment(e); + } + if (docComment == null || docComment.trim().isEmpty() || docComment.contains("{@inheritDoc}")) { //look for inherited doc comments. docComment = findInheritedDocComment(e); @@ -91,7 +101,7 @@ private String findInheritedDocComment(Element e) { for (TypeMirror iface : interfaces) { Element el = iface instanceof DeclaredType ? ((DeclaredType)iface).asElement() : null; if (el != null) { - String docComment = delegate.getDocComment(el); + String docComment = el instanceof ElementAdaptor ? ((ElementAdaptor)el).getDocComment() : delegate.getDocComment(el); if (docComment != null && !docComment.trim().isEmpty()) { return docComment; } @@ -116,8 +126,8 @@ else if (e instanceof ExecutableElement) { if (superType != null) { List methods = ElementFilter.methodsIn(superType.getEnclosedElements()); for (ExecutableElement candidate : methods) { - if (delegate.overrides((ExecutableElement) e, candidate, typeElement)) { - String docComment = delegate.getDocComment(candidate); + if (overrides((ExecutableElement) e, candidate, typeElement)) { + String docComment = candidate instanceof ElementAdaptor ? ((ElementAdaptor)candidate).getDocComment() : delegate.getDocComment(candidate); if (docComment != null && !docComment.trim().isEmpty()) { return docComment; } @@ -132,8 +142,8 @@ else if (e instanceof ExecutableElement) { if (superType != null) { List methods = ElementFilter.methodsIn(superType.getEnclosedElements()); for (ExecutableElement candidate : methods) { - if (delegate.overrides((ExecutableElement) e, candidate, typeElement)) { - String docComment = delegate.getDocComment(candidate); + if (overrides((ExecutableElement) e, candidate, typeElement)) { + String docComment = candidate instanceof ElementAdaptor ? ((ElementAdaptor)candidate).getDocComment() : delegate.getDocComment(candidate); if (docComment != null && !docComment.trim().isEmpty()) { return docComment; } @@ -157,7 +167,7 @@ public boolean isDeprecated(Element e) { e = ((DecoratedElement) e).getDelegate(); } - return delegate.isDeprecated(e); + return e instanceof ElementAdaptor ? ((ElementAdaptor)e).isDeprecated() : delegate.isDeprecated(e); } @Override @@ -166,7 +176,7 @@ public Name getBinaryName(TypeElement type) { type = ((DecoratedTypeElement) type).getDelegate(); } - return delegate.getBinaryName(type); + return type instanceof TypeElementAdaptor ? ((TypeElementAdaptor)type).getBinaryName() : delegate.getBinaryName(type); } @Override @@ -175,7 +185,7 @@ public PackageElement getPackageOf(Element e) { e = ((DecoratedElement) e).getDelegate(); } - return ElementDecorator.decorate(delegate.getPackageOf(e), this.env); + return e instanceof ElementAdaptor ? ((ElementAdaptor)e).getPackage() : ElementDecorator.decorate(delegate.getPackageOf(e), this.env); } @Override @@ -184,7 +194,7 @@ public List getAllMembers(TypeElement type) { type = ((DecoratedTypeElement) type).getDelegate(); } - return ElementDecorator.decorate(delegate.getAllMembers(type), this.env); + return type instanceof TypeElementAdaptor ? ((TypeElementAdaptor)type).getAllMembers() : ElementDecorator.decorate(delegate.getAllMembers(type), this.env); } @Override @@ -193,7 +203,7 @@ public List getAllAnnotationMirrors(Element e) { e = ((DecoratedElement) e).getDelegate(); } - return ElementDecorator.decorateAnnotationMirrors(delegate.getAllAnnotationMirrors(e), this.env); + return e instanceof ElementAdaptor ? ((ElementAdaptor)e).getAllAnnotationMirrors() : ElementDecorator.decorateAnnotationMirrors(delegate.getAllAnnotationMirrors(e), this.env); } @Override @@ -206,30 +216,43 @@ public boolean hides(Element hider, Element hidden) { hidden = ((DecoratedElement) hidden).getDelegate(); } + if (hider instanceof ElementAdaptor) { + return ((ElementAdaptor)hider).hides(hidden); + } + + if (hidden instanceof ElementAdaptor) { + return ((ElementAdaptor)hidden).isHiddenBy(hider); + } + return delegate.hides(hider, hidden); } @Override public boolean overrides(ExecutableElement overrider, ExecutableElement overridden, TypeElement type) { - System.out.println("Overrider1 is " + overrider + " overriden is " + overridden); while (overrider instanceof DecoratedExecutableElement) { overrider = ((DecoratedExecutableElement) overrider).getDelegate(); } + if (overrider instanceof ExecutableElementAdaptor) { + return ((ExecutableElementAdaptor)overrider).overrides(overridden, type); + } + while (overridden instanceof DecoratedExecutableElement) { overridden = ((DecoratedExecutableElement) overridden).getDelegate(); } + if (overridden instanceof ExecutableElementAdaptor) { + return ((ExecutableElementAdaptor)overridden).isOverriddenBy(overrider, type); + } + while (type instanceof DecoratedTypeElement) { type = ((DecoratedTypeElement) type).getDelegate(); } - //Lombok decoration has null delegate - if (overrider == null) { - return false; + if (type instanceof TypeElementAdaptor) { + return ((TypeElementAdaptor)type).overrides(overrider, overridden); } - System.out.println("Overrider2 is " + overrider + " overriden is " + overridden); return delegate.overrides(overrider, overridden, type); } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedProcessingEnvironment.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedProcessingEnvironment.java index 2d2461a03..1bb39410c 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedProcessingEnvironment.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/DecoratedProcessingEnvironment.java @@ -19,6 +19,7 @@ import com.sun.source.util.SourcePositions; import com.sun.source.util.TreePath; import com.sun.source.util.Trees; +import com.webcohesion.enunciate.javac.decorations.adaptors.ElementAdaptor; import com.webcohesion.enunciate.javac.decorations.element.DecoratedElement; import javax.annotation.processing.Filer; @@ -104,6 +105,10 @@ public SourcePosition findSourcePosition(Element element) { element = ((DecoratedElement) element).getDelegate(); } + if (element instanceof ElementAdaptor) { + return ((ElementAdaptor)element).getSourcePosition(); + } + TreePath path = this.trees.getPath(element); if (path != null) { CompilationUnitTree cu = path.getCompilationUnit(); diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/ElementAdaptor.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/ElementAdaptor.java new file mode 100644 index 000000000..6fce05b2a --- /dev/null +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/ElementAdaptor.java @@ -0,0 +1,28 @@ +package com.webcohesion.enunciate.javac.decorations.adaptors; + +import com.webcohesion.enunciate.javac.decorations.SourcePosition; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.PackageElement; +import java.util.List; + +/** + * @author Ryan Heaton + */ +public interface ElementAdaptor extends Element { + + String getDocComment(); + + boolean isDeprecated(); + + PackageElement getPackage(); + + List getAllAnnotationMirrors(); + + boolean hides(Element hidden); + + boolean isHiddenBy(Element hider); + + SourcePosition getSourcePosition(); +} diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/ExecutableElementAdaptor.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/ExecutableElementAdaptor.java new file mode 100644 index 000000000..6ea98851f --- /dev/null +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/ExecutableElementAdaptor.java @@ -0,0 +1,14 @@ +package com.webcohesion.enunciate.javac.decorations.adaptors; + +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; + +/** + * @author Ryan Heaton + */ +public interface ExecutableElementAdaptor extends ExecutableElement, ElementAdaptor { + + boolean overrides(ExecutableElement overridden, TypeElement scope); + + boolean isOverriddenBy(ExecutableElement overrider, TypeElement type); +} diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/PackageElementAdaptor.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/PackageElementAdaptor.java new file mode 100644 index 000000000..8148cb341 --- /dev/null +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/PackageElementAdaptor.java @@ -0,0 +1,9 @@ +package com.webcohesion.enunciate.javac.decorations.adaptors; + +import javax.lang.model.element.PackageElement; + +/** + * @author Ryan Heaton + */ +public interface PackageElementAdaptor extends PackageElement, ElementAdaptor { +} diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/TypeElementAdaptor.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/TypeElementAdaptor.java new file mode 100644 index 000000000..9244dae65 --- /dev/null +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/TypeElementAdaptor.java @@ -0,0 +1,19 @@ +package com.webcohesion.enunciate.javac.decorations.adaptors; + +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Name; +import javax.lang.model.element.TypeElement; +import java.util.List; + +/** + * @author Ryan Heaton + */ +public interface TypeElementAdaptor extends TypeElement, ElementAdaptor { + + Name getBinaryName(); + + List getAllMembers(); + + boolean overrides(ExecutableElement overrider, ExecutableElement overridden); +} diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/TypeParameterElementAdaptor.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/TypeParameterElementAdaptor.java new file mode 100644 index 000000000..b901ce11c --- /dev/null +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/TypeParameterElementAdaptor.java @@ -0,0 +1,9 @@ +package com.webcohesion.enunciate.javac.decorations.adaptors; + +import javax.lang.model.element.TypeParameterElement; + +/** + * @author Ryan Heaton + */ +public interface TypeParameterElementAdaptor extends TypeParameterElement, ElementAdaptor { +} diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/VariableElementAdaptor.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/VariableElementAdaptor.java new file mode 100644 index 000000000..9b65f4cf3 --- /dev/null +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/adaptors/VariableElementAdaptor.java @@ -0,0 +1,9 @@ +package com.webcohesion.enunciate.javac.decorations.adaptors; + +import javax.lang.model.element.VariableElement; + +/** + * @author Ryan Heaton + */ +public interface VariableElementAdaptor extends VariableElement, ElementAdaptor { +} diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java index e3951e8c7..e022992ae 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java @@ -29,8 +29,6 @@ import java.lang.annotation.Annotation; import java.util.*; -import static com.sun.tools.javac.jvm.ByteCodes.ret; - @SuppressWarnings("unchecked") public class DecoratedElement implements Element { @@ -228,11 +226,6 @@ public ElementKind getKind() { @Override public Element getEnclosingElement() { if (this.enclosingElement == null) { - if (this.delegate == null) { - System.out.println("Delegate is null for " + this + " of class " + this.getClass()); - return null; - - } this.enclosingElement = ElementDecorator.decorate(delegate.getEnclosingElement(), env); } @@ -251,9 +244,6 @@ public List getEnclosedElements() { @Override public R accept(ElementVisitor v, P p) { return v.visitUnknown(this, p); -// throw new IllegalArgumentException("KATARAKTA"); -// System.out.println("Accept visitor " + v + " and property " + p + " on this " + this.getClass()); -// return v.visit(this, p); } //Inherited. @@ -299,7 +289,7 @@ public boolean equals(Object obj) { //Inherited. public String toString() { - return this.delegate == null ? null : this.delegate.toString(); + return this.delegate.toString(); } } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/ElementUtils.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/ElementUtils.java index 47d155438..8db5321ed 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/ElementUtils.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/ElementUtils.java @@ -95,4 +95,8 @@ else if (Object.class.getName().equals(fqn)) { return false; } + + public static String capitalize(String string) { + return Character.toUpperCase(string.charAt(0)) + string.substring(1); + } } diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/PropertyElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/PropertyElement.java index e25f87d86..adb11e3df 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/PropertyElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/PropertyElement.java @@ -16,10 +16,16 @@ package com.webcohesion.enunciate.javac.decorations.element; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.*; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.ElementVisitor; +import javax.lang.model.element.Name; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; import java.lang.annotation.Annotation; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * A property, representing the getter/setter pair. In all cases, the description of the property matches the description of the @@ -43,14 +49,6 @@ public class PropertyElement extends DecoratedExecutableElement { */ public PropertyElement(DecoratedExecutableElement getter, DecoratedExecutableElement setter, ProcessingEnvironment env) { super(getter == null ? setter : getter); - - DecoratedExecutableElement wtf = getter == null ? setter : getter; - if (wtf.env == null) { - System.out.println("Null env for " + wtf.getClass() + wtf); - throw new IllegalArgumentException(); - } - - this.getter = getter; this.setter = setter; this.propertyName = getter != null ? getter.getPropertyName() : setter.getPropertyName(); diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java index 799b8db03..d5d01daa6 100644 --- a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokDecoration.java @@ -16,17 +16,14 @@ public class LombokDecoration extends SimpleElementVisitor6 getTypeParameters() { + return Collections.emptyList(); + } + + @Override + public TypeMirror getReturnType() { + return this.var.asType(); + } + + @Override + public List getParameters() { + return Collections.emptyList(); + } + + @Override + public boolean isVarArgs() { + return false; + } + + @Override + public List getThrownTypes() { + return Collections.emptyList(); + } + + @Override + public AnnotationValue getDefaultValue() { + return null; + } + + @Override + public Name getSimpleName() { + return simpleName; + } + + @Override + public TypeMirror asType() { + return new Type(); + } + + @Override + public ElementKind getKind() { + return ElementKind.METHOD; + } + + @Override + public List getAnnotationMirrors() { + return this.var.getAnnotationMirrors(); + } + + @Override + public A getAnnotation(Class annotationType) { + return this.var.getAnnotation(annotationType); + } + + @Override + public Set getModifiers() { + return EnumSet.of(Modifier.PUBLIC); + } + + @Override + public Element getEnclosingElement() { + return this.var.getEnclosingElement(); + } + + @Override + public List getEnclosedElements() { + return Collections.emptyList(); + } + + @Override + public R accept(ElementVisitor v, P p) { + return v.visitExecutable(this, p); + } + + @Override + public boolean overrides(ExecutableElement overridden, TypeElement scope) { + return (overridden instanceof LombokGeneratedGetter) && (this.env.getElementUtils().hides(this.var, ((LombokGeneratedGetter) overridden).var)); + } + + @Override + public String getDocComment() { + String docComment = this.env.getElementUtils().getDocComment(this.var); + if (docComment != null && !docComment.trim().isEmpty()) { + return docComment + "\n@return " + this.var.getSimpleName().toString() + ' ' + docComment; + } + return null; + } + + @Override + public boolean isDeprecated() { + return this.env.getElementUtils().isDeprecated(this.var); + } + + @Override + public boolean isOverriddenBy(ExecutableElement overrider, TypeElement type) { + return (overrider instanceof LombokGeneratedGetter) && ((LombokGeneratedGetter) overrider).overrides(this, type); + } + + @Override + public PackageElement getPackage() { + return this.env.getElementUtils().getPackageOf(this.var); + } + + @Override + public List getAllAnnotationMirrors() { + return this.env.getElementUtils().getAllAnnotationMirrors(this.var); + } + + @Override + public boolean hides(Element hidden) { + return false; + } + + @Override + public boolean isHiddenBy(Element hider) { + return false; + } + + @Override + public SourcePosition getSourcePosition() { + return this.env.findSourcePosition(this.var); + } + + private class Type implements ExecutableType { + + @Override + public List getTypeVariables() { + return Collections.emptyList(); + } + + @Override + public TypeMirror getReturnType() { + return var.asType(); + } + + @Override + public List getParameterTypes() { + return Collections.emptyList(); + } + + @Override + public List getThrownTypes() { + return Collections.emptyList(); + } + + @Override + public TypeKind getKind() { + return TypeKind.EXECUTABLE; + } + + @Override + public R accept(TypeVisitor v, P p) { + return v.visitExecutable(this, p); + } + } +} diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokGeneratedSetter.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokGeneratedSetter.java new file mode 100644 index 000000000..8ba724cf1 --- /dev/null +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokGeneratedSetter.java @@ -0,0 +1,187 @@ +package com.webcohesion.enunciate.modules.lombok; + +import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; +import com.webcohesion.enunciate.javac.decorations.SourcePosition; +import com.webcohesion.enunciate.javac.decorations.adaptors.ExecutableElementAdaptor; +import com.webcohesion.enunciate.javac.decorations.element.ElementUtils; + +import javax.lang.model.element.*; +import javax.lang.model.type.*; +import java.lang.annotation.Annotation; +import java.util.Collections; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; + +/** + * @author Ryan Heaton + */ +public class LombokGeneratedSetter implements ExecutableElementAdaptor { + + private final VariableElement var; + private final DecoratedProcessingEnvironment env; + private final Name simpleName; + + public LombokGeneratedSetter(VariableElement var, DecoratedProcessingEnvironment env) { + this.var = var; + this.env = env; + this.simpleName = this.env.getElementUtils().getName("set" + ElementUtils.capitalize(this.var.getSimpleName().toString())); + } + + @Override + public List getTypeParameters() { + return Collections.emptyList(); + } + + @Override + public TypeMirror getReturnType() { + return this.env.getTypeUtils().getNoType(TypeKind.VOID); + } + + @Override + public List getParameters() { + return Collections.singletonList(this.var); + } + + @Override + public boolean isVarArgs() { + return false; + } + + @Override + public List getThrownTypes() { + return Collections.emptyList(); + } + + @Override + public AnnotationValue getDefaultValue() { + return null; + } + + @Override + public Name getSimpleName() { + return simpleName; + } + + @Override + public TypeMirror asType() { + return new Type(); + } + + @Override + public ElementKind getKind() { + return ElementKind.METHOD; + } + + @Override + public List getAnnotationMirrors() { + return this.var.getAnnotationMirrors(); + } + + @Override + public A getAnnotation(Class annotationType) { + return this.var.getAnnotation(annotationType); + } + + @Override + public Set getModifiers() { + return EnumSet.of(Modifier.PUBLIC); + } + + @Override + public Element getEnclosingElement() { + return this.var.getEnclosingElement(); + } + + @Override + public List getEnclosedElements() { + return Collections.emptyList(); + } + + @Override + public R accept(ElementVisitor v, P p) { + return v.visitExecutable(this, p); + } + + @Override + public boolean overrides(ExecutableElement overridden, TypeElement scope) { + return (overridden instanceof LombokGeneratedSetter) && (this.env.getElementUtils().hides(this.var, ((LombokGeneratedSetter) overridden).var)); + } + + @Override + public String getDocComment() { + String docComment = this.env.getElementUtils().getDocComment(this.var); + if (docComment != null && !docComment.trim().isEmpty()) { + return docComment + "\n@param " + this.var.getSimpleName().toString() + ' ' + docComment; + } + return null; + } + + @Override + public boolean isDeprecated() { + return this.env.getElementUtils().isDeprecated(this.var); + } + + @Override + public boolean isOverriddenBy(ExecutableElement overrider, TypeElement type) { + return (overrider instanceof LombokGeneratedSetter) && ((LombokGeneratedSetter) overrider).overrides(this, type); + } + + @Override + public PackageElement getPackage() { + return this.env.getElementUtils().getPackageOf(this.var); + } + + @Override + public List getAllAnnotationMirrors() { + return this.env.getElementUtils().getAllAnnotationMirrors(this.var); + } + + @Override + public boolean hides(Element hidden) { + return false; + } + + @Override + public boolean isHiddenBy(Element hider) { + return false; + } + + @Override + public SourcePosition getSourcePosition() { + return this.env.findSourcePosition(this.var); + } + + private class Type implements ExecutableType { + + @Override + public List getTypeVariables() { + return Collections.emptyList(); + } + + @Override + public TypeMirror getReturnType() { + return env.getTypeUtils().getNoType(TypeKind.VOID); + } + + @Override + public List getParameterTypes() { + return Collections.singletonList(var.asType()); + } + + @Override + public List getThrownTypes() { + return Collections.emptyList(); + } + + @Override + public TypeKind getKind() { + return TypeKind.EXECUTABLE; + } + + @Override + public R accept(TypeVisitor v, P p) { + return v.visitExecutable(this, p); + } + } +} diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodGenerator.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodGenerator.java index 2c9eea11d..ca20cb0b0 100644 --- a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodGenerator.java +++ b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodGenerator.java @@ -28,16 +28,11 @@ public LombokMethodGenerator(DecoratedTypeElement decoratedTypeElement, Decorate public void generateLombokGettersAndSetters() { List fields = decoratedTypeElement.getFields(); for (VariableElement field : fields) { - System.out.println("Field " + field.getSimpleName() + " of class " + field.getClass().getSimpleName()); - -// DecoratedVariableElement decoratedVariableElement = (DecoratedVariableElement) field; if (shouldGenerateGetter(field)) { - System.out.println("Adding getter to " + decoratedTypeElement + " " + System.identityHashCode(decoratedTypeElement) + " for field " + field); - decoratedTypeElement.getMethods().add(new LombokPropertyDecoratedExecutableElement(field, env, true)); + decoratedTypeElement.getMethods().add(new DecoratedExecutableElement(new LombokGeneratedGetter(field, env), env)); } if (shouldGenerateSetter(field)) { - System.out.println("Adding setter to " + decoratedTypeElement + " " + System.identityHashCode(decoratedTypeElement) + " for field " + field); - decoratedTypeElement.getMethods().add(new LombokPropertyDecoratedExecutableElement(field, env, false)); + decoratedTypeElement.getMethods().add(new DecoratedExecutableElement(new LombokGeneratedSetter(field, env), env)); } } } diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodSymbol.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodSymbol.java deleted file mode 100644 index d1459bbc3..000000000 --- a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokMethodSymbol.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.webcohesion.enunciate.modules.lombok; - -import com.sun.tools.javac.code.Symbol; - -public class LombokMethodSymbol extends Symbol.MethodSymbol { - public LombokMethodSymbol(VarSymbol varSymbol) { - super(varSymbol.flags(), varSymbol.name, varSymbol.type, varSymbol.owner); - } -} diff --git a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java b/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java deleted file mode 100644 index 6d15823fc..000000000 --- a/lombok/src/main/java/com/webcohesion/enunciate/modules/lombok/LombokPropertyDecoratedExecutableElement.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.webcohesion.enunciate.modules.lombok; - -import com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment; -import com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement; - -import javax.lang.model.element.*; -import javax.lang.model.type.TypeMirror; -import java.lang.annotation.Annotation; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -/** - * @author Tomasz Kalkosiński - */ -public class LombokPropertyDecoratedExecutableElement extends DecoratedExecutableElement implements ExecutableElement { - - private VariableElement variableElement; - private boolean getter; - - public LombokPropertyDecoratedExecutableElement(VariableElement variableElement, DecoratedProcessingEnvironment env, boolean getter) { - super(null, env); - this.variableElement = variableElement; - this.getter = getter; - } - - @Override - public List getTypeParameters() { - return null; - } - - @Override - public TypeMirror getReturnType() { - return getter ? variableElement.asType() : null; - } - - @Override - public List getParameters() { - return getter ? Collections.emptyList() : Collections.singletonList(variableElement); - } - - @Override - public boolean isVarArgs() { - return false; - } - - @Override - public List getThrownTypes() { - return null; - } - - @Override - public AnnotationValue getDefaultValue() { - return null; - } - - @Override - public TypeMirror asType() { - return variableElement.asType(); - } - - @Override - public ElementKind getKind() { - return variableElement.getKind(); - } - - @Override - public List getAnnotationMirrors() { - return variableElement.getAnnotationMirrors(); - } - - @Override - public A getAnnotation(Class annotationType) { - return variableElement.getAnnotation(annotationType); - } - - @Override - public Set getModifiers() { - return Collections.singleton(Modifier.PUBLIC); - } - - /** - * This probably should return a Name with "get"/"set"/"is" prefix but it's hard to put a new Name into SharedNameTable. - * @returns variableElement#getSimpleName() until it creates some blocker issue that needs to improve it - */ - @Override - public Name getSimpleName() { - return variableElement.getSimpleName(); - } - - @Override - public Element getEnclosingElement() { - return variableElement.getEnclosingElement(); - } - - @Override - public List getEnclosedElements() { - return variableElement.getEnclosedElements(); - } - - @Override - public String getPropertyName() { - return variableElement.getSimpleName().toString(); - } - - @Override - public String toString() { - return variableElement == null ? null : variableElement.toString(); - } - - @Override - public boolean isGetter() { - return getter; - } - - @Override - public boolean isSetter() { - return !getter; - } -} \ No newline at end of file From 3d7d543d7e71a6044c7e459aa8d4efe54e1439ed Mon Sep 17 00:00:00 2001 From: Ryan Heaton Date: Fri, 23 Sep 2016 14:33:20 -0600 Subject: [PATCH 09/12] deploy artifact shouldn't default packaing to project's packaging; fixes #473 --- .../com/webcohesion/enunciate/mojo/DeployArtifactBaseMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slim-maven-plugin/src/main/java/com/webcohesion/enunciate/mojo/DeployArtifactBaseMojo.java b/slim-maven-plugin/src/main/java/com/webcohesion/enunciate/mojo/DeployArtifactBaseMojo.java index 37dd1cd68..a2831c0b4 100644 --- a/slim-maven-plugin/src/main/java/com/webcohesion/enunciate/mojo/DeployArtifactBaseMojo.java +++ b/slim-maven-plugin/src/main/java/com/webcohesion/enunciate/mojo/DeployArtifactBaseMojo.java @@ -116,7 +116,7 @@ public class DeployArtifactBaseMojo extends AbstractMojo implements Contextualiz /** * Type of the artifact to be deployed. Retrieved from POM file if specified. */ - @Parameter( defaultValue = "${project.packaging}") + @Parameter protected String packaging; /** From 474c4f06ade6e9bd2259dfcc7dcdda50d8a42b62 Mon Sep 17 00:00:00 2001 From: darmbrust Date: Mon, 26 Sep 2016 10:40:30 -0500 Subject: [PATCH 10/12] Patch for https://github.com/stoicflame/enunciate/issues/506 --- .../modules/ruby_json_client/api.fmt | 11 ++++++ .../ruby_json_client/client-complex-type.fmt | 36 +++++++++---------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ruby-json-client/src/main/resources/com/webcohesion/enunciate/modules/ruby_json_client/api.fmt b/ruby-json-client/src/main/resources/com/webcohesion/enunciate/modules/ruby_json_client/api.fmt index b8e39fcd8..61a744022 100644 --- a/ruby-json-client/src/main/resources/com/webcohesion/enunciate/modules/ruby_json_client/api.fmt +++ b/ruby-json-client/src/main/resources/com/webcohesion/enunciate/modules/ruby_json_client/api.fmt @@ -87,6 +87,17 @@ class Hash end end +module EnunciateHelpers + LAMB_CLASS_AWARE = ->(_item) do + java_clazz = _item['@class'] + clazz_array_parts = java_clazz.split('.') + short_clazz = clazz_array_parts.pop + clazz_package = clazz_array_parts.map do |e| e[0] = e.first.capitalize; e end.join("::") + clazz = clazz_package + "::" + short_clazz + Object.const_get(clazz).send(:from_json, _item) + end +end + [#list schemaTypes as typeDefinition] [#if !isFacetExcluded(typeDefinition)] [#if typeDefinition.enum] diff --git a/ruby-json-client/src/main/resources/com/webcohesion/enunciate/modules/ruby_json_client/client-complex-type.fmt b/ruby-json-client/src/main/resources/com/webcohesion/enunciate/modules/ruby_json_client/client-complex-type.fmt index 0a0d27dd2..cc37ff07e 100644 --- a/ruby-json-client/src/main/resources/com/webcohesion/enunciate/modules/ruby_json_client/client-complex-type.fmt +++ b/ruby-json-client/src/main/resources/com/webcohesion/enunciate/modules/ruby_json_client/client-complex-type.fmt @@ -89,25 +89,25 @@ module ${submodule} [#else] [#list type.members as member] [#if !isFacetExcluded(member)] - [#if member.collectionType] - if !_o['${member.name}'].nil? - @${member.clientSimpleName} = Array.new - _oa = _o['${member.name}'] - _oa.each { | _item | - if ((_item.nil? || _item['@class'].nil?)rescue true) - @${member.clientSimpleName}.push ${classnameFor(member.collectionItemType)}.from_json(_item) - else - clazz_array_parts = _item['@class'].split('.') - short_clazz = clazz_array_parts.pop - clazz_package = clazz_array_parts.map do |e| e[0] = e.first.capitalize; e end.join("::") - clazz = clazz_package + "::" + short_clazz - @${member.clientSimpleName}.push Object.const_get(clazz).send(:from_json, _item) + if !_o['${member.name}'].nil? + _oa = _o['${member.name}'] + if(_oa.is_a? Hash) + @${member.clientSimpleName} = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class'] + @${member.clientSimpleName} = [#if (member.collectionItemType)??]${classnameFor(member.collectionItemType)}[#else]${classnameFor(member)}[/#if].from_json(_oa) unless _oa['@class'] + elsif (_oa.is_a? Array) + #an array(of hashes hopefully) or scalar + @${member.clientSimpleName} = Array.new + _oa.each { | _item | + if ((_item.nil? || _item['@class'].nil?)rescue true) + @${member.clientSimpleName}.push [#if (member.collectionItemType)??]${classnameFor(member.collectionItemType)}[#else]${classnameFor(member)}[/#if].from_json(_item) + else + @${member.clientSimpleName}.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item) + end + } + else + @${member.clientSimpleName} = _oa + end end - } - end - [#else] - @${member.clientSimpleName} = ${classnameFor(member)}.from_json(_o['${member.name}']) unless _o['${member.name}'].nil? - [/#if] [/#if] [/#list] [/#if] From 96ff22624955653e910967dc42e4dc3226cfb839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kalkosi=C5=84ski?= Date: Mon, 3 Oct 2016 23:52:09 +0200 Subject: [PATCH 11/12] More combinations of lombok annotations --- .../jaxrsjackson/genealogy/data/Event.java | 38 ++++--------------- .../jaxrsjackson/genealogy/data/Gender.java | 3 ++ .../jaxrsjackson/genealogy/data/Name.java | 5 +++ .../jaxrsjackson/genealogy/data/Person.java | 4 ++ 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Event.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Event.java index 7ab8fa7a6..0609866cc 100644 --- a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Event.java +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Event.java @@ -15,6 +15,9 @@ */ package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; +import lombok.Getter; +import lombok.Setter; + import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Arrays; @@ -27,29 +30,15 @@ */ public class Event extends OccurringAssertion { + @Getter + @Setter private EventType type; + @Setter private String description; private final List tags = new ArrayList(); + @Getter private String explanation; - /** - * The type of this event. - * - * @return The type of this event. - */ - public EventType getType() { - return type; - } - - /** - * The type of this event. - * - * @param type The type of this event. - */ - public void setType(EventType type) { - this.type = type; - } - /** * A description of this event. * @@ -60,15 +49,6 @@ public String getDescription() { return description; } - /** - * A description of this event. - * - * @param description A description of this event. - */ - public void setDescription(String description) { - this.description = description; - } - public String[] getTags() { return tags.toArray(new String[tags.size()]); } @@ -78,10 +58,6 @@ public void setTags(String tags[]) { this.tags.addAll(Arrays.asList(tags)); } - public String getExplanation() { - return explanation; - } - public void setExplanation(String explanation) { this.explanation = explanation; } diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Gender.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Gender.java index bb5c11ced..8b9f7d051 100644 --- a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Gender.java +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Gender.java @@ -15,11 +15,14 @@ */ package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; +import lombok.Data; + /** * A gender assertion. * * @author Ryan Heaton */ +@Data public class Gender extends Assertion { private GenderType type; diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Name.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Name.java index 2f42cfd27..948007d27 100644 --- a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Name.java +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Name.java @@ -15,11 +15,16 @@ */ package com.webcohesion.enunciate.examples.jaxrsjackson.genealogy.data; +import lombok.Getter; +import lombok.Setter; + /** * A name assertion. An example name is Yamada Tarō (山田太郎). * * @author Ryan Heaton */ +@Getter +@Setter public class Name extends Assertion { private String value; diff --git a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Person.java b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Person.java index b2e4833c5..2fc3e3ca1 100644 --- a/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Person.java +++ b/examples/jackson2-api-lombok/src/main/java/com/webcohesion/enunciate/examples/jaxrsjackson/genealogy/data/Person.java @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.webcohesion.enunciate.metadata.Label; +import lombok.Getter; +import lombok.Setter; import java.util.Collection; import java.util.Map; @@ -29,6 +31,8 @@ @JsonSerialize public class Person { + @Getter + @Setter private String id; private Gender gender; private Collection names; From 1f2a5e9397f3fcb19aac140779e5164b44df2f63 Mon Sep 17 00:00:00 2001 From: Ryan Heaton Date: Thu, 6 Oct 2016 16:47:10 -0600 Subject: [PATCH 12/12] minor lombok cleanup --- examples/jackson2-api-lombok/enunciate.xml | 7 ------- examples/jackson2-api-lombok/pom.xml | 5 ----- examples/jackson2-api/enunciate.xml | 7 ------- .../javac/decorations/element/DecoratedElement.java | 3 +-- 4 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 examples/jackson2-api-lombok/enunciate.xml delete mode 100644 examples/jackson2-api/enunciate.xml diff --git a/examples/jackson2-api-lombok/enunciate.xml b/examples/jackson2-api-lombok/enunciate.xml deleted file mode 100644 index 3d7fdbc8a..000000000 --- a/examples/jackson2-api-lombok/enunciate.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/examples/jackson2-api-lombok/pom.xml b/examples/jackson2-api-lombok/pom.xml index 9fb1b3a83..57e91fcfd 100644 --- a/examples/jackson2-api-lombok/pom.xml +++ b/examples/jackson2-api-lombok/pom.xml @@ -25,11 +25,6 @@ assemble - - - java-json-client - - diff --git a/examples/jackson2-api/enunciate.xml b/examples/jackson2-api/enunciate.xml deleted file mode 100644 index 3d7fdbc8a..000000000 --- a/examples/jackson2-api/enunciate.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java index e022992ae..96e5e5862 100644 --- a/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java +++ b/javac-support/src/main/java/com/webcohesion/enunciate/javac/decorations/element/DecoratedElement.java @@ -45,8 +45,7 @@ public DecoratedElement(E delegate, DecoratedProcessingEnvironment env) { this.delegate = delegate; this.env = env; - //env can be null for decorations - if (this.env != null && this.env.getElementDecorations() != null) { + if (this.env.getElementDecorations() != null) { for (ElementDecoration elementDecoration : this.env.getElementDecorations()) { elementDecoration.applyTo(this, this.env); }