olidroide / Immutables-Android-Example

Example of use Immutables 2.0 fro Android and GSON

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Immutables Android Example

Small example of use Immutables 2.0 for Android and GSON. You can also follow the Android start guide of Immutables

With the follow User model:

@Gson.TypeAdapters
@Value.Immutable
public abstract class User {

    public abstract int id();

    public abstract String username();
}

We can use it as:

User user = ImmutableUser.builder().id(1).username("olidroide").build();

Serialize:

String jsonUser = new JsonFromUser().map(user);

Deserialize:

User user = new UserFromJson().map(jsonUser);

More info

http://immutables.github.io/immutable.html

Thanks to

About

Example of use Immutables 2.0 fro Android and GSON

License:GNU General Public License v3.0


Languages

Language:Java 100.0%