Repository: joelittlejohn/jsonschema2pojo (java)

Issue:
Add Moshi to annotation styles
It would be great if you could add [Moshi](https://github.com/square/moshi) to list of _Annotation styles_ and output the POJOs accordingly.

/cc @square @JakeWharton

Pull request description:
Add Moshi 1.x annotation style
Resolves #523.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bc2a5af0..a607e917 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,11 +1,5 @@
 # Changelog
 
-## 0.4.22
-* Adding date-time types to Maven plugin mojo configuration ([#531](https://github.com/joelittlejohn/jsonschema2pojo/pull/531))
-* Fix javaName breaking required properties ([#528](https://github.com/joelittlejohn/jsonschema2pojo/pull/528))
-* Add support for using BigDecimal to represent numbers ([#517](https://github.com/joelittlejohn/jsonschema2pojo/pull/517))
-* Jsonschema2pojoRule report problems to STDERR ([#513](https://github.com/joelittlejohn/jsonschema2pojo/pull/513))
-
 ## 0.4.21
 * Fix NullPointerException in Gradle plugin for Java (non-Android) projects ([#510](https://github.com/joelittlejohn/jsonschema2pojo/pull/510))
 
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index dbc0dffa..c06aaa20 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -49,10 +49,7 @@
 * P Wilder
 * Rakshith Rao (rakrao)
 * Lomig Megard
-* Rami Baksansky
 * Dimitrij Drus
 * Arno Puder
 * SpaceBison
-* Mike Woudenberg
 * Tobias Preuss
-* Max Myslyvtsev
diff --git a/README.md b/README.md
index 070e5c19..a24a9759 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ A very simple Maven example:
 <plugin>
     <groupId>org.jsonschema2pojo</groupId>
     <artifactId>jsonschema2pojo-maven-plugin</artifactId>
-    <version>0.4.22</version>
+    <version>0.4.21</version>
     <configuration>
         <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
         <targetPackage>com.example.types</targetPackage>
@@ -30,9 +30,9 @@ Useful pages:
   * **[Getting started](https://github.com/joelittlejohn/jsonschema2pojo/wiki/Getting-Started)**
   * **[How to contribute](https://github.com/joelittlejohn/jsonschema2pojo/wiki/Contribute)**
   * [Reference](https://github.com/joelittlejohn/jsonschema2pojo/wiki/Reference)
-  * [Latest Javadocs](http://joelittlejohn.github.io/jsonschema2pojo/javadocs/0.4.22/)
-  * [Documentation for the Maven plugin](http://joelittlejohn.github.io/jsonschema2pojo/site/0.4.22/generate-mojo.html)
-  * [Documentation for the Ant task](http://joelittlejohn.github.io/jsonschema2pojo/site/0.4.22/Jsonschema2PojoTask.html)
+  * [Latest Javadocs](http://joelittlejohn.github.io/jsonschema2pojo/javadocs/0.4.21/)
+  * [Documentation for the Maven plugin](http://joelittlejohn.github.io/jsonschema2pojo/site/0.4.21/generate-mojo.html)
+  * [Documentation for the Ant task](http://joelittlejohn.github.io/jsonschema2pojo/site/0.4.21/Jsonschema2PojoTask.html)
 
 Project resources:
   * [Downloads](https://github.com/joelittlejohn/jsonschema2pojo/releases)
diff --git a/jsonschema2pojo-ant/pom.xml b/jsonschema2pojo-ant/pom.xml
index da7b4c1a..ec61359a 100644
--- a/jsonschema2pojo-ant/pom.xml
+++ b/jsonschema2pojo-ant/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <artifactId>jsonschema2pojo</artifactId>
         <groupId>org.jsonschema2pojo</groupId>
-        <version>0.4.23-SNAPSHOT</version>
+        <version>0.4.22-SNAPSHOT</version>
     </parent>
 
     <artifactId>jsonschema2pojo-ant</artifactId>
diff --git a/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html b/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html
index 51a5c499..249ab30a 100644
--- a/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html
+++ b/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html
@@ -38,6 +38,7 @@
             <li><code>JACKSON2</code> (apply annotations from the <a href="https://github.com/FasterXML/jackson-annotations">Jackson 2.x</a> library)</li>
             <li><code>JACKSON1</code> (apply annotations from the <a href="http://jackson.codehaus.org/">Jackson 1.x</a> library)</li>
             <li><code>GSON</code> (apply annotations from the <a href="https://code.google.com/p/google-gson//">Gson</a> library)</li>
+            <li><code>MOSHI1</code> (apply annotations from the <a href="https://github.com/square/moshi//">Moshi 1.x</a> library)</li>
             <li><code>NONE</code> (apply no annotations at all)</li>
           </ul>
         </td>
diff --git a/jsonschema2pojo-cli/pom.xml b/jsonschema2pojo-cli/pom.xml
index dd557057..61617ba3 100644
--- a/jsonschema2pojo-cli/pom.xml
+++ b/jsonschema2pojo-cli/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <artifactId>jsonschema2pojo</artifactId>
         <groupId>org.jsonschema2pojo</groupId>
-        <version>0.4.23-SNAPSHOT</version>
+        <version>0.4.22-SNAPSHOT</version>
     </parent>
 
     <artifactId>jsonschema2pojo-cli</artifactId>
diff --git a/jsonschema2pojo-core/pom.xml b/jsonschema2pojo-core/pom.xml
index 0d66a465..c599135d 100644
--- a/jsonschema2pojo-core/pom.xml
+++ b/jsonschema2pojo-core/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <artifactId>jsonschema2pojo</artifactId>
         <groupId>org.jsonschema2pojo</groupId>
-        <version>0.4.23-SNAPSHOT</version>
+        <version>0.4.22-SNAPSHOT</version>
     </parent>
 
     <artifactId>jsonschema2pojo-core</artifactId>
@@ -33,6 +33,10 @@
             <groupId>com.google.code.gson</groupId>
             <artifactId>gson</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.squareup.moshi</groupId>
+            <artifactId>moshi</artifactId>
+        </dependency>
         <dependency>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/AnnotationStyle.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/AnnotationStyle.java
index 0ce6fcbf..dee82d4a 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/AnnotationStyle.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/AnnotationStyle.java
@@ -52,6 +52,14 @@ public enum AnnotationStyle {
      */
     GSON,
 
+    /**
+     * Moshi 1.x
+     *
+     * @see <
+     *      href="https://github.com/square/moshi">https://github.com/square/moshi</a>
+     */
+    MOSHI1,
+
     /**
      * No-op style, adds no annotations at all.
      */
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Annotator.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Annotator.java
index ce55ab86..3419cf9e 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Annotator.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Annotator.java
@@ -149,7 +149,8 @@ public interface Annotator {
      * annotators, this method will return <code>true</code>. Gson does not
      * support 'additional' property values (they are silently discarded at
      * deserialization time), hence for Gson annotators, this method would
-     * return <code>false</code>.
+     * return <code>false</code>. Moshi 1.x behaves similar to Gson and therefore
+     * returns <code>false</code>.
      * 
      * @return Whether this annotator has any way to support 'additional
      *         properties'.
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/AnnotatorFactory.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/AnnotatorFactory.java
index eb90a494..b482f34d 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/AnnotatorFactory.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/AnnotatorFactory.java
@@ -41,6 +41,8 @@ public class AnnotatorFactory {
                 return new Jackson1Annotator();
             case GSON:
                 return new GsonAnnotator();
+            case MOSHI1:
+                return new Moshi1Annotator();
             case NONE:
                 return new NoopAnnotator();
             default:
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java
index f8c71318..71405a2e 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java
@@ -145,6 +145,9 @@ public interface GenerationConfig {
      *         <li><code>gson</code> (apply annotations from the
      *         <a href="https://code.google.com/p/google-gson/">gson</a>
      *         library)</li>
+     *         <li><code>moshi1</code> (apply annotations from the
+     *         <a href="https://github.com/square/moshi">moshi</a>
+     *         library)</li>
      *         <li><code>none</code> (apply no annotations at all)</li>
      *         </ul>
      * @see AnnotatorFactory
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Moshi1Annotator.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Moshi1Annotator.java
new file mode 100644
index 00000000..cad8df81
--- /dev/null
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Moshi1Annotator.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright © 2016 Tobias Preuss
+ *
+ * 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 org.jsonschema2pojo;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.squareup.moshi.Json;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JEnumConstant;
+import com.sun.codemodel.JFieldVar;
+
+/**
+ * Annotates generated Java types using Moshi. The annotations used here are most
+ * useful when the JSON fields have characters (like underscores) that are
+ * poorly suited for beans. By using the {@link Json} annotation, we
+ * are able to preserve the original format.
+ *
+ * @see <a
+ *      href="https://github.com/square/moshi#custom-field-names-with-json">https://github.com/square/moshi#custom-field-names-with-json</a>
+ */
+public class Moshi1Annotator extends AbstractAnnotator {
+
+    @Override
+    public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) {
+        field.annotate(Json.class).param("name", propertyName);
+    }
+
+    @Override
+    public void enumConstant(JEnumConstant constant, String value) {
+        constant.annotate(Json.class).param("name", value);
+    }
+
+    @Override
+    public boolean isAdditionalPropertiesSupported() {
+        return false;
+    }
+
+}
diff --git a/jsonschema2pojo-gradle-plugin/README.md b/jsonschema2pojo-gradle-plugin/README.md
index 79d25ad6..e267fa30 100644
--- a/jsonschema2pojo-gradle-plugin/README.md
+++ b/jsonschema2pojo-gradle-plugin/README.md
@@ -87,6 +87,7 @@ jsonSchema2Pojo {
   //  - jackson2 (apply annotations from the Jackson 2.x library)
   //  - jackson1 (apply annotations from the Jackson 1.x library)
   //  - gson (apply annotations from the Gson library)
+  //  - moshi1 (apply annotations from the Moshi 1.x library)
   //  - none (apply no annotations at all)
   annotationStyle = 'jackson'
 
diff --git a/jsonschema2pojo-gradle-plugin/example/android/app/build.gradle b/jsonschema2pojo-gradle-plugin/example/android/app/build.gradle
index 94dfd470..d98f95ef 100644
--- a/jsonschema2pojo-gradle-plugin/example/android/app/build.gradle
+++ b/jsonschema2pojo-gradle-plugin/example/android/app/build.gradle
@@ -43,6 +43,8 @@ dependencies {
     compile 'org.glassfish:javax.annotation:10.0-b28'
     // Required if generating Gson annotations
     compile 'com.google.code.gson:gson:2.5'
+    // Required if generating Moshi 1.x annotations
+    compile 'com.squareup.moshi:moshi:1.1.0'
     // Required if generating equals, hashCode, or toString methods
     compile 'commons-lang:commons-lang:2.6'
     // Required if generating JSR-303 annotations
@@ -98,6 +100,7 @@ jsonSchema2Pojo {
     //  - jackson2 (apply annotations from the Jackson 2.x library)
     //  - jackson1 (apply annotations from the Jackson 1.x library)
     //  - gson (apply annotations from the Gson library)
+    //  - moshi1 (apply annotations from the Moshi 1.x library)
     //  - none (apply no annotations at all)
     annotationStyle = 'gson'
 
diff --git a/jsonschema2pojo-gradle-plugin/example/android/lib/build.gradle b/jsonschema2pojo-gradle-plugin/example/android/lib/build.gradle
index 5842a6a8..9f05d6d8 100644
--- a/jsonschema2pojo-gradle-plugin/example/android/lib/build.gradle
+++ b/jsonschema2pojo-gradle-plugin/example/android/lib/build.gradle
@@ -42,6 +42,8 @@ dependencies {
     compile 'org.glassfish:javax.annotation:10.0-b28'
     // Required if generating Gson annotations
     compile 'com.google.code.gson:gson:2.5'
+    // Required if generating Moshi 1.x annotations
+    compile 'com.squareup.moshi:moshi:1.1.0'
     // Required if generating equals, hashCode, or toString methods
     compile 'commons-lang:commons-lang:2.6'
     // Required if generating JSR-303 annotations
@@ -96,6 +98,7 @@ jsonSchema2Pojo {
     //  - jackson2 (apply annotations from the Jackson 2.x library)
     //  - jackson1 (apply annotations from the Jackson 1.x library)
     //  - gson (apply annotations from the Gson library)
+    //  - moshi1 (apply annotations from the Moshi 1.x library)
     //  - none (apply no annotations at all)
     annotationStyle = 'gson'
 
diff --git a/jsonschema2pojo-gradle-plugin/pom.xml b/jsonschema2pojo-gradle-plugin/pom.xml
index ef10a7b0..86e0e94a 100644
--- a/jsonschema2pojo-gradle-plugin/pom.xml
+++ b/jsonschema2pojo-gradle-plugin/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <artifactId>jsonschema2pojo</artifactId>
         <groupId>org.jsonschema2pojo</groupId>
-        <version>0.4.23-SNAPSHOT</version>
+        <version>0.4.22-SNAPSHOT</version>
     </parent>
 
     <artifactId>jsonschema2pojo-gradle-plugin</artifactId>
diff --git a/jsonschema2pojo-maven-plugin/pom.xml b/jsonschema2pojo-maven-plugin/pom.xml
index f1d08adc..f74be456 100644
--- a/jsonschema2pojo-maven-plugin/pom.xml
+++ b/jsonschema2pojo-maven-plugin/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <artifactId>jsonschema2pojo</artifactId>
         <groupId>org.jsonschema2pojo</groupId>
-        <version>0.4.23-SNAPSHOT</version>
+        <version>0.4.22-SNAPSHOT</version>
     </parent>
 
     <artifactId>jsonschema2pojo-maven-plugin</artifactId>
diff --git a/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java b/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
index e47bf991..db27eaf2 100644
--- a/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
+++ b/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
@@ -215,6 +215,8 @@ public class Jsonschema2PojoMojo extends AbstractMojo implements GenerationConfi
      * <a href="http://jackson.codehaus.org/">Jackson 1.x</a> library)</li>
      * <li><code>gson</code> (apply annotations from the
      * <a href="https://code.google.com/p/google-gson/">gson</a> library)</li>
+     * <li><code>moshi1</code> (apply annotations from the
+     * <a href="https://github.com/square/moshi">moshi 1.x</a> library)</li>
      * <li><code>none</code> (apply no annotations at all)</li>
      * </ul>
      *
@@ -345,31 +347,8 @@ public class Jsonschema2PojoMojo extends AbstractMojo implements GenerationConfi
      */
     private boolean useJodaLocalTimes = false;
 
-    /**
-     * What type to use instead of string when adding string type fields of
-     * format date-time to generated Java types.
-     *
-     * @parameter expression="${jsonschema2pojo.dateTimeType}"
-     * @since 0.4.22
-     */
     private String dateTimeType = null;
-
-    /**
-     * What type to use instead of string when adding string type fields of
-     * format time (not date-time) to generated Java types.
-     *
-     * @parameter expression="${jsonschema2pojo.timeType}"
-     * @since 0.4.22
-     */
     private String timeType = null;
-
-    /**
-     * What type to use instead of string when adding string type fields of
-     * format date (not date-time) to generated Java types.
-     *
-     * @parameter expression="${jsonschema2pojo.dateType}"
-     * @since 0.4.22
-     */
     private String dateType = null;
 
     /**
diff --git a/pom.xml b/pom.xml
index e639c3b1..b58f9c69 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
 
     <groupId>org.jsonschema2pojo</groupId>
     <artifactId>jsonschema2pojo</artifactId>
-    <version>0.4.23-SNAPSHOT</version>
+    <version>0.4.22-SNAPSHOT</version>
 
     <packaging>pom</packaging>
     <name>jsonschema2pojo</name>
@@ -53,6 +53,7 @@
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <gradle.version>1.6</gradle.version>
         <gson.version>2.5</gson.version>
+        <moshi.version>1.1.0</moshi.version>
     </properties>
 
     <build>
@@ -296,6 +297,11 @@
                 <artifactId>gson</artifactId>
                 <version>${gson.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.squareup.moshi</groupId>
+                <artifactId>moshi</artifactId>
+                <version>${moshi.version}</version>
+            </dependency>
             <dependency>
                 <groupId>com.google.code.javaparser</groupId>
                 <artifactId>javaparser</artifactId>


Test patch:
diff --git a/jsonschema2pojo-core/src/test/java/org/jsonschema2pojo/AnnotatorFactoryTest.java b/jsonschema2pojo-core/src/test/java/org/jsonschema2pojo/AnnotatorFactoryTest.java
index 1694aa33..8aed5a13 100644
--- a/jsonschema2pojo-core/src/test/java/org/jsonschema2pojo/AnnotatorFactoryTest.java
+++ b/jsonschema2pojo-core/src/test/java/org/jsonschema2pojo/AnnotatorFactoryTest.java
@@ -37,6 +37,7 @@ public class AnnotatorFactoryTest {
         assertThat(factory.getAnnotator(JACKSON), is(instanceOf(Jackson2Annotator.class)));
         assertThat(factory.getAnnotator(JACKSON2), is(instanceOf(Jackson2Annotator.class)));
         assertThat(factory.getAnnotator(GSON), is(instanceOf(GsonAnnotator.class)));
+        assertThat(factory.getAnnotator(MOSHI1), is(instanceOf(Moshi1Annotator.class)));
         assertThat(factory.getAnnotator(NONE), is(instanceOf(NoopAnnotator.class)));
 
     }
diff --git a/jsonschema2pojo-integration-tests/pom.xml b/jsonschema2pojo-integration-tests/pom.xml
index 592d9ae3..056959b8 100644
--- a/jsonschema2pojo-integration-tests/pom.xml
+++ b/jsonschema2pojo-integration-tests/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <artifactId>jsonschema2pojo</artifactId>
         <groupId>org.jsonschema2pojo</groupId>
-        <version>0.4.23-SNAPSHOT</version>
+        <version>0.4.22-SNAPSHOT</version>
     </parent>
 
     <artifactId>jsonschema2pojo-integration-tests</artifactId>
diff --git a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/Moshi1IT.java b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/Moshi1IT.java
new file mode 100644
index 00000000..452f84c8
--- /dev/null
+++ b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/Moshi1IT.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright © 2016 Tobias Preuss
+ *
+ * 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 org.jsonschema2pojo.integration.config;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.google.gson.Gson;
+import com.squareup.moshi.JsonAdapter;
+import com.squareup.moshi.Moshi;
+import org.apache.commons.io.IOUtils;
+import org.jsonschema2pojo.integration.util.Jsonschema2PojoRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import static org.hamcrest.Matchers.*;
+import static org.jsonschema2pojo.integration.util.CodeGenerationHelper.config;
+import static org.jsonschema2pojo.integration.util.FileSearchMatcher.containsText;
+import static org.jsonschema2pojo.integration.util.JsonAssert.assertEqualsJson;
+import static org.junit.Assert.assertThat;
+
+public class Moshi1IT {
+
+    @Rule
+    public Jsonschema2PojoRule schemaRule = new Jsonschema2PojoRule();
+
+    private Moshi moshi;
+
+    @Before
+    public void setUp() {
+        moshi = new Moshi.Builder().build();
+    }
+
+    @Test
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public void annotationStyleMoshi1ProducesMoshi1Annotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException, NoSuchFieldException {
+
+        Class generatedType = schemaRule.generateAndCompile("/json/examples/torrent.json", "com.example",
+                config("annotationStyle", "moshi1",
+                        "propertyWordDelimiters", "_",
+                        "sourceType", "json"))
+                .loadClass("com.example.Torrent");
+
+        assertThat(schemaRule.getGenerateDir(), not(containsText("org.codehaus.jackson")));
+        assertThat(schemaRule.getGenerateDir(), not(containsText("com.fasterxml.jackson")));
+        assertThat(schemaRule.getGenerateDir(), not(containsText("com.google.gson")));
+        assertThat(schemaRule.getGenerateDir(), not(containsText("@SerializedName")));
+        assertThat(schemaRule.getGenerateDir(), containsText("com.squareup.moshi"));
+        assertThat(schemaRule.getGenerateDir(), containsText("@Json"));
+
+        Method getter = generatedType.getMethod("getBuild");
+
+        assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(nullValue()));
+        assertThat(generatedType.getAnnotation(JsonInclude.class), is(nullValue()));
+        assertThat(getter.getAnnotation(JsonProperty.class), is(nullValue()));
+    }
+
+    @Test
+    public void annotationStyleMoshi1MakesTypesThatWorkWithMoshi1() throws ClassNotFoundException, SecurityException, NoSuchMethodException, NoSuchFieldException, IOException {
+
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/json/examples/", "com.example",
+                config("annotationStyle", "moshi1",
+                        "propertyWordDelimiters", "_",
+                        "sourceType", "json",
+                        "useLongIntegers", true));
+
+        assertJsonRoundTrip(resultsClassLoader, "com.example.Torrent", "/json/examples/torrent.json");
+        assertJsonRoundTrip(resultsClassLoader, "com.example.GetUserData", "/json/examples/GetUserData.json");
+    }
+
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    @Test
+    public void enumValuesAreSerializedCorrectly() throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+
+        ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/enum/typeWithEnumProperty.json", "com.example",
+                config("annotationStyle", "moshi1",
+                        "propertyWordDelimiters", "_"));
+
+        Class generatedType = resultsClassLoader.loadClass("com.example.TypeWithEnumProperty");
+        Class enumType = resultsClassLoader.loadClass("com.example.TypeWithEnumProperty$EnumProperty");
+        Object instance = generatedType.newInstance();
+
+        Method setter = generatedType.getMethod("setEnumProperty", enumType);
+        setter.invoke(instance, enumType.getEnumConstants()[3]);
+
+        JsonAdapter jsonAdapter = moshi.adapter(generatedType);
+        String json = jsonAdapter.toJson(instance);
+
+        Map<String, String> jsonAsMap = new Gson().fromJson(json, Map.class);
+        assertThat(jsonAsMap.get("enum_Property"), is("4 ! 1"));
+    }
+
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    private void assertJsonRoundTrip(ClassLoader resultsClassLoader, String className, String jsonResource) throws ClassNotFoundException, IOException {
+        Class generatedType = resultsClassLoader.loadClass(className);
+
+        String expectedJson = IOUtils.toString(getClass().getResource(jsonResource));
+        JsonAdapter<Object> jsonAdapter = moshi.adapter(generatedType);
+        Object javaInstance = jsonAdapter.fromJson(expectedJson);
+        String actualJson = jsonAdapter.toJson(javaInstance);
+
+        assertEqualsJson(expectedJson, actualJson);
+    }
+
+}