Skip to content

Commit

Permalink
Initial project import
Browse files Browse the repository at this point in the history
  • Loading branch information
ndtaylor committed Apr 14, 2016
1 parent 6293b60 commit 2b37642
Show file tree
Hide file tree
Showing 165 changed files with 11,483 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local.properties
**/build/

**.iml
.idea/

.gradle/
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Contributing
============

If you would like to contribute, you can do so by forking the repository and sending a pull request.

Please follow the existing style. You may import the code style into IntilliJ or Android Studio by
copying the [code style file](./workday-oss-code-style.xml) into the following directory, depending
on your operating system.

- Windows: `<your home directory>\.<product name><version number>\config\codestyles`
- Linux: `~/.<product name><version number>/config/codestyles`
- OS X: `~/Library/Preferences/<product name><version number>/codestyles`

Restart IntelliJ or Android Studio. Then go to Settings > Editor > Code Style and select
"workday-oss-code-style".

From the root directory, please run `./gradlew assemble check` before submitting your pull request
to make sure that you didn't break anything.
14 changes: 14 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright 2016 Workday, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# autoparse-json

Coming soon!

Autoparse JSON is a java library built specifically for Android that uses code generation to parse JSON into custom objects in your project.

**Latest Version:** [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.workday/autoparse-json/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.workday/autoparse-json)

**Build Status:** [![Circle CI](https://circleci.com/gh/Workday/autoparse-json.svg?style=svg)](https://circleci.com/gh/Workday/autoparse-json)
Empty file added build.gradle
Empty file.
143 changes: 143 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">

<module name="Checker">

<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>

<module name="FileLength"/>
<module name="FileTabCharacter"/>

<!-- Trailing spaces -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>

<!-- Space after 'for' and 'if' -->
<module name="RegexpSingleline">
<property name="format" value="^\s*(for|if)\("/>
<property name="message" value="Space needed before opening parenthesis."/>
</module>

<!-- For each spacing -->
<module name="RegexpSingleline">
<property name="format" value="^\s*for \(.*?([^ ]:|:[^ ])"/>
<property name="message" value="Space needed around ':' character."/>
</module>

<module name="TreeWalker">

<module name="FileContentsHolder"/>

<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocStyle"/>
<module name="NonEmptyAtclauseDescription"/>

<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<!--<module name="ConstantName"/>-->
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="ConstantName"/>
<module name="ClassTypeParameterName"/>


<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<!-- processJavadoc doesn't seem to be working -->
<!--<module name="UnusedImports">-->
<!--<property name="processJavadoc" value="true"/>-->
<!--</module>-->

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="120"/>
</module>
<module name="MethodLength">
<property name="max" value="200"/>
</module>

<!--module name="ParameterNumber"/-->


<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="GenericWhitespace"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap">
<property name="tokens"
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR"/>
</module>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>

<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier">
<!-- Do not check constructors -->
<property name="tokens"
value="INTERFACE_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, CLASS_DEF, ENUM_DEF"/>
</module>


<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<module name="EmptyBlock">
<property name="option" value="text"/>
</module>


<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<module name="CovariantEquals"/>
<module name="DefaultComesLast"/>
<module name="EmptyStatement"/>
<module name="EqualsAvoidNull"/>
<module name="EqualsHashCode"/>
<module name="FallThrough"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MissingSwitchDefault"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>

<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<module name="HideUtilityClassConstructor"/>
<module name="OneTopLevelClass"/>


<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="UpperEll"/>
</module>
</module>
33 changes: 33 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
dependencies:
pre:
- echo y | android update sdk --no-ui --all --filter "tools,platform-tools,android-23"
- echo y | android update sdk --no-ui --all --filter "build-tools-23.0.2"

test:
override:
- ./gradlew build
post:
- mkdir -p $CIRCLE_TEST_REPORTS/xml-reports/core $CIRCLE_TEST_REPORTS/xml-reports/processor
- mkdir -p $CIRCLE_TEST_REPORTS/xml-reports/demo/debug $CIRCLE_TEST_REPORTS/xml-reports/demo/release
- mkdir -p $CIRCLE_TEST_REPORTS/html-reports/core $CIRCLE_TEST_REPORTS/html-reports/processor
- mkdir -p $CIRCLE_TEST_REPORTS/html-reports/demo/debug $CIRCLE_TEST_REPORTS/html-reports/demo/release
- mkdir -p $CIRCLE_ARTIFACTS/checkstyle/core $CIRCLE_ARTIFACTS/checkstyle/processor
- mkdir -p $CIRCLE_ARTIFACTS/lint
- mkdir -p $CIRCLE_ARTIFACTS/jars
# XML Test Reports
- cp core/build/test-results/TEST-*.xml $CIRCLE_TEST_REPORTS/xml-reports/core/
- cp processor/build/test-results/TEST-*.xml $CIRCLE_TEST_REPORTS/xml-reports/processor/
- cp demo/build/test-results/debug/TEST-*.xml $CIRCLE_TEST_REPORTS/xml-reports/demo/debug/
- cp demo/build/test-results/release/TEST-*.xml $CIRCLE_TEST_REPORTS/xml-reports/demo/release/
# HTML Test Reports
- cp -r core/build/reports/tests/* $CIRCLE_TEST_REPORTS/html-reports/core/
- cp -r processor/build/reports/tests/* $CIRCLE_TEST_REPORTS/html-reports/processor/
- cp -r demo/build/reports/tests/debug/* $CIRCLE_TEST_REPORTS/html-reports/demo/debug/
- cp -r demo/build/reports/tests/release/* $CIRCLE_TEST_REPORTS/html-reports/demo/release/
# Checkstyle
- cp core/build/reports/checkstyle/*.xml $CIRCLE_ARTIFACTS/checkstyle/core/
- cp processor/build/reports/checkstyle/*.xml $CIRCLE_ARTIFACTS/checkstyle/processor/
# Lint
- cp -r demo/build/outputs/lint* $CIRCLE_ARTIFACTS/lint/
# Jars
- cp -r core/build/libs/*.jar processor/build/libs/*.jar $CIRCLE_ARTIFACTS/jars
21 changes: 21 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apply plugin: 'java'
apply from: file('../gradle/artifact-naming.gradle')
apply from: file('../gradle/gradle-mvn-push.gradle')
apply from: file('../gradle/provided-configuration.gradle')
apply from: file('../gradle/checkstyle.gradle')

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

repositories {
mavenCentral()
}

dependencies {
provided('com.google.android:android:4.1.1.4')
compile 'com.workday:metajava:1.1'

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.robolectric:robolectric:3.0'
}
3 changes: 3 additions & 0 deletions core/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_ARTIFACT_ID=autoparse-json
POM_NAME=Autoparse JSON
POM_PACKAGING=jar
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2016 Workday, Inc.
*
* This software is available under the MIT license.
* Please see the LICENSE.txt file in this project.
*/

package com.workday.autoparse.json.annotations;

/**
* Indicate to Autoparse that this field (or setter) should be populated (or called) with the
* discrimination value for this object. The field will be populated or the setter called only if
* the discrimination value occurs in the json document. Autoparse will not attempt to pull the
* discrimination value from the {@literal@}{@link JsonObject} annotation on the class. This
* annotation is only valid on non-private, non-final fields and non-private, single argument
* methods (setters) which can accept a value of type {@link String}.
*
* @author nathan.taylor
* @since 2015-02-18
*/
public @interface DiscrimValue {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright 2016 Workday, Inc.
*
* This software is available under the MIT license.
* Please see the LICENSE.txt file in this project.
*/

package com.workday.autoparse.json.annotations;

import com.workday.autoparse.json.context.JsonParserSettings;
import com.workday.autoparse.json.parser.JsonObjectParser;
import com.workday.autoparse.json.parser.NoJsonObjectParser;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Indicates to the Autoparse JSON framework that this class can be instantiated and inflated during
* the parsing of a JSON document. The targeted class must have a non-private, no-argument
* constructor.
* <p/>
* If no arguments are provided to this annotation, then a parser will be generated for this class,
* and a new instance of this class may be created and inflated when required by another object
* (e.g. when this class is the type of a field for an object being parsed).
*
* @author nathan.taylor
* @since 2014-10-09
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface JsonObject {

/**
* This field tells Autoparse that if any of the values listed here are found paired with the
* name corresponding to {@link JsonParserSettings#getDiscriminationName()} on an object in a
* JSON document, then an instance of the target class should be created and inflated from that
* JSON object.
* <p/>
* Note however that if the object in the JSON object is a child of another JSON object whose
* type is known, then an object of the type of that field will be created instead.
* <p/>
* For example, suppose that there are three objects in your project, Parent, ChildA, and ChildB
* defined as such:
* <pre>
* {@literal@}JsonObject("parent")
* public class Parent {
* {@literal@}JsonValue("myChildA") ChildA myChildA;
* }
*
* {@literal@}JsonObject("childA")
* public class ChildA { }
*
* {@literal@}JsonObject("childB")
* public class ChildB { }
* </pre>
* <p/>
* And suppose that we have the following JSON document to parse, where the discrimination key
* is "key".
* <pre>
* {
* "key":"parent",
* "myChildA":{
* "key":"childB"
* }
* }
* </pre>
* In this case, the top most object has a discrimination value of "parent" which corresponds to
* the Parent object, so Autoparse will create an instance of Parent as the root object. The
* child object has a field name of "myChildA". Autoparse knows that anything corresponding to
* "myChildA" must be a ChildA object, so Autoparse creates a ChildA object for that object in
* the JSON document, even though the discrimination value for that object tells Autoparse to
* create an instance of ChildB. Thus the values in this annotation are only used if there are
* no other hints about what type the object to be parsed should be.
* <p/>
* Because of this, you are not required to provide a value here. Placing this annotation on a
* class will merely register the class with Autoparse as a known type that can be instantiated
* when required.
*/
String[] value() default {};

/**
* You may optionally supply your own {@link JsonObjectParser} to parse this class. If a class
* is supplied here, then Autoparse will not generate a parser for this object, but will instead
* use an instance of the class supplied to perform the parsing when an object of this type is
* needed.
* <p/>
* <b>NOTE: </b> Any class provided here <b>must</b> have a {@code public static} field named
* {@code INSTANCE}, which Autoparse will use as the instance of this parser.
*/
Class<? extends JsonObjectParser<?>> parser() default NoJsonObjectParser.class;
}
Loading

0 comments on commit 2b37642

Please sign in to comment.