Repository: incubator-streams Updated Branches: refs/heads/master c64da77f2 -> c49624a17 Updated Tags: refs/tags/streams-internal-0.11.0 [created] 67233d9d7 refs/tags/streams-project-0.1 [created] 20bf832ff refs/tags/streams-project-0.1.0-W2O [created] c416827a1 refs/tags/streams-project-0.1.1-W2O [created] 4ad6346c9 refs/tags/streams-project-0.1.2-W2O [created] d872eab87 refs/tags/streams-project-0.1.2-W2O-HF1 [created] ad054a186 refs/tags/streams-project-0.1.4-W2O [created] be409217e refs/tags/streams-project-0.1.5-W2O [created] 73d0037ff refs/tags/streams-project-0.1.6-W2O [created] dfa7081ce refs/tags/streams-project-0.1.7-W2O [created] bf98c2e32 refs/tags/streams-project-0.1.8-W2O [created] 974a779e0 refs/tags/streams-project-0.2.0-W2O [created] c34ba7fde refs/tags/streams-project-0.2.1-W2O [created] 958616fa0 refs/tags/streams-project-0.2.10-W2O [created] c0c243f43 refs/tags/streams-project-0.2.11-W2O [created] 346271837 refs/tags/streams-project-0.2.12-W2O [created] 6fa5dab3a refs/tags/streams-project-0.2.13-W2O [created] 89db62833 refs/tags/streams-project-0.2.14-W2O [created] 344e02e83 refs/tags/streams-project-0.2.2-W2O [created] dd97112b9 refs/tags/streams-project-0.2.3-W2O [created] 97bccc30c refs/tags/streams-project-0.2.4-W2O [created] 594c1c9b3 refs/tags/streams-project-0.2.5-W2O [created] 455d20016 refs/tags/streams-project-0.2.6-W2O [created] f1aff01bb refs/tags/streams-project-0.2.7-W2O [created] 7907d6336 refs/tags/streams-project-0.2.8-W2O [created] 45289bf88 refs/tags/streams-project-0.2.9-W2O [created] e9c355ba5 refs/tags/streams-project-0.3-PP [created] 89e9a912b refs/tags/streams-project-0.3-PP-rc1 [created] d05fb8589 refs/tags/streams-project-0.3.1-PP [created] 361bb6036 refs/tags/streams-project-0.3.3-PP [created] 26d2b5c4b refs/tags/streams-project-0.3.4-PP [created] e5391c6dd refs/tags/streams-project-0.3.6-PP [created] a79363362 refs/tags/streams-project-0.3.7-PP [created] c2f1cdd8d refs/tags/streams-project-0.3.8-PP [created] bd3a174e6 refs/tags/streams-project-0.3.9-PP [created] c05400bb0 refs/tags/streams-project-0.5-incubating-rc1 [created] 0a9c4aaf0
STREAMS-512: add juneau annotations to all generated pojos also add juneau-core to streams-pojo and streams-config Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/c49624a1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/c49624a1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/c49624a1 Branch: refs/heads/master Commit: c49624a17ece024dc9f4567535f47904a4884232 Parents: c64da77 Author: Steve Blackmon @steveblackmon <sblack...@apache.org> Authored: Tue May 23 02:31:57 2017 -0500 Committer: Steve Blackmon @steveblackmon <sblack...@apache.org> Committed: Tue May 23 02:31:57 2017 -0500 ---------------------------------------------------------------------- streams-config/pom.xml | 5 ++ streams-plugins/streams-plugin-pojo/pom.xml | 5 ++ .../streams/plugins/JuneauPojoAnnotator.java | 84 ++++++++++++++++++++ .../plugins/StreamsPojoGenerationConfig.java | 7 ++ streams-pojo/pom.xml | 6 ++ 5 files changed, 107 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/c49624a1/streams-config/pom.xml ---------------------------------------------------------------------- diff --git a/streams-config/pom.xml b/streams-config/pom.xml index 23456c1..137983a 100644 --- a/streams-config/pom.xml +++ b/streams-config/pom.xml @@ -33,6 +33,11 @@ <dependencies> <dependency> + <groupId>org.apache.juneau</groupId> + <artifactId>juneau-core</artifactId> + <version>6.2.1-incubating-SNAPSHOT</version> + </dependency> + <dependency> <groupId>com.typesafe</groupId> <artifactId>config</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/c49624a1/streams-plugins/streams-plugin-pojo/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/pom.xml b/streams-plugins/streams-plugin-pojo/pom.xml index 6a5c60b..35a455b 100644 --- a/streams-plugins/streams-plugin-pojo/pom.xml +++ b/streams-plugins/streams-plugin-pojo/pom.xml @@ -56,6 +56,11 @@ <artifactId>commons-lang3</artifactId> </dependency> <dependency> + <groupId>org.apache.juneau</groupId> + <artifactId>juneau-core</artifactId> + <version>6.2.1-incubating-SNAPSHOT</version> + </dependency> + <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> <version>0.9.9</version> http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/c49624a1/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/JuneauPojoAnnotator.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/JuneauPojoAnnotator.java b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/JuneauPojoAnnotator.java new file mode 100644 index 0000000..64143da --- /dev/null +++ b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/JuneauPojoAnnotator.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.streams.plugins; + +import com.sun.codemodel.JMethod; +import org.apache.juneau.annotation.BeanProperty; +import org.jsonschema2pojo.AbstractAnnotator; + +/** + * Add @BeanProperty annotations to getters, setters, anyGetter, and anySetter + */ +public class JuneauPojoAnnotator extends AbstractAnnotator { + + /** + * Add the necessary annotation to mark a Java method as the getter for a + * JSON property + * + * @param getter + * the method that will be used to get the value of the given + * JSON property + * @param propertyName + * the name of the JSON property that this getter gets + */ + public void propertyGetter(JMethod getter, String propertyName) { + getter.annotate(BeanProperty.class).param("name", propertyName); + } + + /** + * Add the necessary annotation to mark a Java method as the setter for a + * JSON property + * + * @param setter + * the method that will be used to set the value of the given + * JSON property + * @param propertyName + * the name of the JSON property that this setter sets + */ + public void propertySetter(JMethod setter, String propertyName) { + setter.annotate(BeanProperty.class).param("name", propertyName); + } + + /** + * Add the necessary annotation to mark a Java method as the getter for + * additional JSON property values that do not match any of the other + * property names found in the bean. + * + * @param getter + * the method that will be used to get the values of additional + * properties + */ + public void anyGetter(JMethod getter) { + getter.annotate(BeanProperty.class).param("name", "*"); + } + + /** + * Add the necessary annotation to mark a Java method as the setter for + * additional JSON property values that do not match any of the other + * property names found in the bean. + * + * @param setter + * the method that will be used to set the values of additional + * properties + */ + public void anySetter(JMethod setter) { + setter.annotate(BeanProperty.class).param("name", "*"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/c49624a1/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java index d3b15a3..4378b70 100644 --- a/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java +++ b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java @@ -19,7 +19,9 @@ package org.apache.streams.plugins; +import org.jsonschema2pojo.Annotator; import org.jsonschema2pojo.DefaultGenerationConfig; +import org.jsonschema2pojo.NoopAnnotator; import org.jsonschema2pojo.util.URLUtil; import java.io.File; @@ -114,4 +116,9 @@ public class StreamsPojoGenerationConfig extends DefaultGenerationConfig { // return true; // } + @Override + public Class<? extends Annotator> getCustomAnnotator() { + return JuneauPojoAnnotator.class; + } + } http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/c49624a1/streams-pojo/pom.xml ---------------------------------------------------------------------- diff --git a/streams-pojo/pom.xml b/streams-pojo/pom.xml index a4d4e78..8091b2d 100644 --- a/streams-pojo/pom.xml +++ b/streams-pojo/pom.xml @@ -35,6 +35,12 @@ <dependencies> <dependency> + <groupId>org.apache.juneau</groupId> + <artifactId>juneau-core</artifactId> + <version>6.2.1-incubating-SNAPSHOT</version> + </dependency> + + <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> </dependency>