Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #108 from vimeo/release-prep-2-2-0
Browse files Browse the repository at this point in the history
Release prep 2.2.0
  • Loading branch information
anthonycr authored May 30, 2017
2 parents 040b426 + ecc8f48 commit 6be4c9b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

Version 2.2.0 *(2017-05-30)*
----------------------------
- Added support for private member variables in Java (leveraging getters/setters).
- Added support for models written in Kotlin.

Version 2.1.4 *(2017-05-10)*
----------------------------
- Added compiler support for all Java language versions.
Expand Down
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ buildscript {
apply plugin: 'net.ltgt.apt'
dependencies {
compile 'com.vimeo.stag:stag-library:2.1.4'
apt 'com.vimeo.stag:stag-library-compiler:2.1.4'
compile 'com.vimeo.stag:stag-library:2.2.0'
apt 'com.vimeo.stag:stag-library-compiler:2.2.0'
}
// Optional annotation processor arguments (see below)
Expand All @@ -63,8 +63,8 @@ apt {

```groovy
dependencies {
compile 'com.vimeo.stag:stag-library:2.1.4'
annotationProcessor 'com.vimeo.stag:stag-library-compiler:2.1.4'
compile 'com.vimeo.stag:stag-library:2.2.0'
annotationProcessor 'com.vimeo.stag:stag-library-compiler:2.2.0'
}
android {
Expand Down Expand Up @@ -125,13 +125,15 @@ Last but not the least, Stag is almost in parity with GSON.
## Stag Rules

1. Make sure that any private member variables have setters/getters following these naming rules:
```java
private String myString;
```java
private String myString;

public String getMyString() { ... }
public String getMyString() { ... }

public void setMyString(String parameter) { ... }
```
public void setMyString(String parameter) { ... }
```
Java setters and getters must have `protected`, `public`, or package local visibility. If you don't want to use setters and getters, make sure your member variables have `protected`, `public`, or package local visibility.
If working with Kotlin, currently, you must make sure your getters all have `public` visibility. Because stag generates Java code, the only way it knows how to access the Kotlin fields is if the setters and getters are public. By default, the visibility set on a Kotlin member variable is also applied to its setters and getters.
2. Make sure your model class is not private and has a zero argument non-private constructor
3. Annotate the classes with `@UseStag` annotation. This will process all the member variables of the class, which makes it easy to use.
4. Use the `@SerializedName("key")` annotation to give the variables a different JSON name. (same as GSON)
Expand Down Expand Up @@ -238,6 +240,8 @@ MyParsingClass {
## Future Enhancements

- Add an option to absorb parsing errors rather than crashing and halting parsing (default gson behavior)
- Support `internal` visibility in Kotlin code
- Generate Kotlin code for Kotlin models

## Development
```sh
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ allprojects {

subprojects {
group = 'com.vimeo.stag'
version = '2.1.4'
version = '2.2.0'
}

0 comments on commit 6be4c9b

Please sign in to comment.