emaze-maple

A mapper

License

License

Categories

Categories

Net
GroupId

GroupId

net.emaze
ArtifactId

ArtifactId

emaze-maple
Last Version

Last Version

2.3
Release Date

Release Date

Type

Type

jar
Description

Description

emaze-maple
A mapper
Project URL

Project URL

https://github.com/emaze/emaze-maple
Source Code Management

Source Code Management

https://github.com/emaze/emaze-maple

Download emaze-maple

How to add to project

<!-- https://jarcasting.com/artifacts/net.emaze/emaze-maple/ -->
<dependency>
    <groupId>net.emaze</groupId>
    <artifactId>emaze-maple</artifactId>
    <version>2.3</version>
</dependency>
// https://jarcasting.com/artifacts/net.emaze/emaze-maple/
implementation 'net.emaze:emaze-maple:2.3'
// https://jarcasting.com/artifacts/net.emaze/emaze-maple/
implementation ("net.emaze:emaze-maple:2.3")
'net.emaze:emaze-maple:jar:2.3'
<dependency org="net.emaze" name="emaze-maple" rev="2.3">
  <artifact name="emaze-maple" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.emaze', module='emaze-maple', version='2.3')
)
libraryDependencies += "net.emaze" % "emaze-maple" % "2.3"
[net.emaze/emaze-maple "2.3"]

Dependencies

compile (4)

Group / Artifact Type Version
net.emaze : emaze-dysfunctional jar 5.7
org.springframework : spring-core jar 4.0.6.RELEASE
org.hibernate : hibernate-core Optional jar 4.3.4.Final
cglib : cglib Optional jar 3.1

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Emaze Maple

Emaze Maple is a generic Java object mapper library using reflection.

Basic usage example

public class BasicUsageExample {

    public static class PersonDAO {
        public PersonTO getPerson() {
            return new PersonTO("John", "Doe", 45);
        }
        public List<PersonTO> getPersons() {
            return Arrays.asList(
                    new PersonTO("John", "Doe", 45),
                    new PersonTO("Jane", "Doe", 35));
        }

        public void save(PersonTO person) {
            /* persist person to database */
        }
    }

    public static class PersonBO {
        private String firstName;
        private String lastName;
        private long age;

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public void setLastName(String lastName) {
            this.lastName = lastName;
        }

        public void setAge(long age) {
            this.age = age;
        }
    }

    public static class PersonTO {
        private String firstName;
        private String lastName;
        private long age;

        public PersonTO(String firstName, String lastName, long age) {
            this.firstName = firstName;
            this.lastName = lastName;
            this.age = age;
        }
    }

    public final static void main(String args[]) {

        final Mapper mapper = ResolvingMapper.Builder.defaults().build();

        final PersonDAO personDAO = new PersonDAO();
        final PersonTO personTO = personDAO.getPerson();
        final PersonBO personBO = mapper.map(personTO, PersonBO.class);

        Assert.assertEquals(personTO.firstName, personBO.firstName);
        Assert.assertEquals(personTO.lastName, personBO.lastName);
        Assert.assertEquals(personTO.age, personBO.age);

        /* mapping arrays of objects too... */
        final List<PersonTO> personsTO = personDAO.getPersons();
        final List<PersonBO> personsBO = mapper.map(personsTO, PersonBO.class);

        Assert.assertEquals(personsTO.get(0).firstName, personsBO.get(0).firstName);
        Assert.assertEquals(personsTO.get(0).lastName, personsBO.get(0).lastName);
        Assert.assertEquals(personsTO.get(0).age, personsBO.get(0).age);

        Assert.assertEquals(personsTO.get(1).firstName, personsBO.get(1).firstName);
        Assert.assertEquals(personsTO.get(1).lastName, personsBO.get(1).lastName);
        Assert.assertEquals(personsTO.get(1).age, personsBO.get(1).age);

    }
}

Documentation

Questions related to the usage of Emaze Maple should be posted to the [user mailing list][ml].

Where can I get the latest release?

You can pull it from the central Maven repositories:

<dependency>
  <groupId>net.emaze</groupId>
  <artifactId>emaze-maple</artifactId>
  <version>2.3</version>
</dependency>

Contributing

We accept PRs via github. The [developer mailing list][ml] is the main channel of communication for contributors. There are some guidelines which will make applying PRs easier for us:

  • Respect the code style.
  • Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
  • Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running mvn clean test.

License

Creative Commons License

Versions

Version
2.3