Thanks to visit codestin.com
Credit goes to github.com

Skip to content

andrerigon/pretender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

WHY?

Pretender is a library to help to integrate java systems with rest services who return json responses.
You don’t have to write a concrete class ( duplication, argh! ) just to hold some value, which in most cases is what you’ ll do.
Or worse, you would ship your domain classes to the client.

For example, lets suppose a service which returns a person object serialized as json:


{"age":"5","name":"andre","buddies":{"maria":{"name":"maria","age":12}}}

You just write a simple interface like:


interface Person{
   String name();
   Integer age();
   List<Person> buddies;
}

And pretender will generate an implementation for the Person interface, returning the values deserialized from the json.
If your method is named “name”. it will return the “name” field and so on.

If you want to use another name, just annotate you method with


@BindToName("my new property name")

INSTALLATION

git clone git://github.com/andrerigon/pretender.git
cd pretender
mvn install

USAGE

Pretender comes in two flavours:

lazy:


Pretender.gsonLazyDeserializerFor(Person.class, Client.class, ....);

and eager bean deserializer:


Pretender.gsonEagerDeserializerFor(Person.class, Client.class, ....);

each one will return a Gson instance configured to use pretender’s type adapter

About

deserializes json based on an interface and generate runtime implementations for it

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages