Vittorio - 2012-08-06

[Introduction]

How many times did you write code like this:

private EPerson map(Person p) {
    EPerson returnValue = new EPerson();

    returnValue.setId(p.getId());
    returnValue.setName(p.getName());
    returnValue.setSurname(p.getSurname());
    try {
        returnValue.setBirth(DATE_FORMAT.parse(p.getBirth()));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    returnValue.setGender(Gender.valueOf(p.getGender()));

    return returnValue;
}

private Person map(EPerson p) {
    Person returnValue = new Person(
            p.getId(), 
            p.getName(), 
            p.getSurname(), 
            DATE_FORMAT.format(p.getBirth()), 
            p.getGender().name());

    return returnValue;
}

... and how many times you wished a tool that did this work alone, relieving the burden of writing code to copy data from one object to another one and the conversion of numbers / dates to string and vice versa?

Would be nice to write a command like:

EPerson ePerson = session.map(person, EPerson.class);

Person person2 = session.map(ePerson, Person.class);

and assume that there is someone who do the "dirty work" in our place!

JMapper is a library that is born in order to solve this problem, by performing data mapping in an automatic way and a series of more or less complicated conversions of the various fields contained in user's objects.

Moreover, since the mappings are defined through annotations placed directly in the various fields of classes to be mapped, the possibility of errors due to failure of conversion methods or classes updates is strongly reduced.

All this, combined with a complete and fully integrated support of third-party libraries' mapping classes and classes for which no provision was made for the mapping annotations , in order to facilitate integration with existing code, complete the framework for great library which manages the movements of data within or between different layers of applications.

 

Last edit: Vittorio 2012-08-06