EntityMapper

Entity field auto mapper

License

License

GroupId

GroupId

com.github.ckpoint
ArtifactId

ArtifactId

entity-mapper
Last Version

Last Version

0.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

EntityMapper
Entity field auto mapper
Project URL

Project URL

https://github.com/ckpoint/EntityMapper
Source Code Management

Source Code Management

https://github.com/ckpoint/EntityMapper

Download entity-mapper

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
joda-time : joda-time jar 2.10.1
javax.persistence : javax.persistence-api jar 2.2

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.6

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Entity-Mapper

EntityMapper is an intelligent object mapping library that automatically maps objects to Entity class.

EntityMapper depends on [Project Lombok, JODA TIME]

※EntityMaper does not need a setter and getter

Installation

1. MAVEN

 <dependency>
   <groupId>com.github.ckpoint</groupId>
   <artifactId>entity-mapper</artifactId>
   <version>0.0.1</version>
 </dependency>

2. GRADLE

  compile group: 'com.github.ckpoint', name: 'entity-mapper', version: '0.0.1'

Table of Contents

Create Entity

A. extends MapEntity

- MapEntity only has automatic mapping function.

@Entity
@Getter
public class Account extends MapEntity {
    private String name;
    private String email;
    private Long age;
    private Gender gender;

}

B. extends MapBaseEntity

- MapBaseEntity has automatic mapping function and Long type id field.

@Entity
@Getter
public class Account extends MapBaseEntity{
    private String name;
    private String email;
    private Long age;
    private Gender gender;

}

C. extends MapAuditEntity

- MapAuditEntity has automatic mapping function and id, createdAt, updatedAt fields.

@Entity
@Getter
public class Account extends MapAuditEntity{
    private String name;
    private String email;
    private Long age;
    private Gender gender;

}

Update Entity

  • The class inheriting EntityMapper has a function called updateFromObj
  • EntityMaper does not need a setter method.

for exmaple

    public void updateEntityTest() {
        AccountModel hsimModel = new AccountModel();
        hsimModel.setAge(25L);
        hsimModel.setEmail("[email protected]");
        hsimModel.setGender("MAN");
        hsimModel.setName("hsim");

        Account hsim = new Account();
        hsim.updateFromObj(hsimModel);
    }

Handling Field Method

  • If you want to exclude certain fields or setter functions from automatic mapping, You just need to put the @IgnoreUpdateFromObj annotation.

for exmaple

@Entity
@Getter
public class Account extends MapAuditModel {
    private String name;
    private String email;

    @IgnoreUpdateFromObj
    private Long age;

    private Gender gender;

    @IgnoreUpdateFromObj
    public void setAge(Long age) {
        this.age = age;
    }
}

Versions

Version
0.0.2
0.0.1