This tool converts Java model classes to their Ember Data equivalent. Here is an example :
POJO model
public class User {
private String firstName;
private String lastName;
private User manager;
private String email;
private Date birthDate;
private Boolean active;
@JsonIgnore
private String password;
@JsonBackReference
private Group group;
}
Ember Data model
App.User = DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
manager: DS.belongsTo('user'),
email: DS.attr('string'),
birthDate: DS.attr('date'),
active: DS.attr('boolean')
});
As you can see in the example, Jackson Annotations are supported out of the box.
- Clone this repository:
git clone https://github.com/worldline/pojo-to-ember-data.git
- Build with Gradle:
./gradlew build
- Drop the generated JAR located in build\libs inside your project classpath.
Here's a basic usage example :
String[] packagesToScan = new String[] { "org.yourcompany.yourproject" };
String emberModelNamespace = "App";
Config config = new Config(packagesToScan, emberModelNamespace);
POJO2EmberData converter = new POJO2EmberData(config);
converter.convert(); // Your models will be generated in the generated_models dir
Check out the test classes for more detailed examples.