sk.annotation.library.jam:jam-tests

JAM as Java Annotation Mapper is mapping at compile time without reflection !

License

License

GroupId

GroupId

sk.annotation.library.jam
ArtifactId

ArtifactId

jam-tests
Last Version

Last Version

0.9.1
Release Date

Release Date

Type

Type

jar
Description

Description

JAM as Java Annotation Mapper is mapping at compile time without reflection !

Download jam-tests

How to add to project

<!-- https://jarcasting.com/artifacts/sk.annotation.library.jam/jam-tests/ -->
<dependency>
    <groupId>sk.annotation.library.jam</groupId>
    <artifactId>jam-tests</artifactId>
    <version>0.9.1</version>
</dependency>
// https://jarcasting.com/artifacts/sk.annotation.library.jam/jam-tests/
implementation 'sk.annotation.library.jam:jam-tests:0.9.1'
// https://jarcasting.com/artifacts/sk.annotation.library.jam/jam-tests/
implementation ("sk.annotation.library.jam:jam-tests:0.9.1")
'sk.annotation.library.jam:jam-tests:jar:0.9.1'
<dependency org="sk.annotation.library.jam" name="jam-tests" rev="0.9.1">
  <artifact name="jam-tests" type="jar" />
</dependency>
@Grapes(
@Grab(group='sk.annotation.library.jam', module='jam-tests', version='0.9.1')
)
libraryDependencies += "sk.annotation.library.jam" % "jam-tests" % "0.9.1"
[sk.annotation.library.jam/jam-tests "0.9.1"]

Dependencies

compile (1)

Group / Artifact Type Version
sk.annotation.library.jam : jam-common jar 0.9.1

provided (2)

Group / Artifact Type Version
sk.annotation.library.jam : jam-processor jar 0.9.1
org.projectlombok : lombok jar 1.18.2

test (4)

Group / Artifact Type Version
junit : junit jar 4.12
org.junit.jupiter : junit-jupiter-api jar 5.4.2
org.junit.jupiter : junit-jupiter-engine jar 5.4.2
org.mockito : mockito-core jar 1.9.5

Project Modules

There are no modules declared in this project.

JAM as Java Annotation Mapper is mapping at compile time without reflection !

What is JAM ?

JAM stands for Java Annotation Mapper is inspired by project SELMA (visit: http://www.selma-java.org/).

JAM library contains an Annotation Processor that generates effective Java code to handle the mapping from one object (or objects) to other at compile time. Result of this process is:

  • efficiently generated Java class
  • very fast code in runtime
  • without other additional dependencies at runtime (only jam-common.jar ~ 9.5 KB)

Why JAM mapper is good to use

JAM library:

  • significantly reduces developer's time
  • improvement quality of code
  • improvement speed of development
    • a lot of problems are resolved by mapper generator
  • mapper is generated during compilation
    • detected problem at compilation time
    • runtime is very fast
  • solving a lot of often problems as:
    • problem with cyclic dependencies in runtime
    • problem with object instances
    • problem with shared context data (as cache of instances)
    • problem with different but compatible types between internal and external sources (WebServices,JAXB,...)
    • support for injection containers as CDI or Spring

How to add it into project ?

First add library jam-processor as a provided dependency and jam-common as a compile dependency to your build.

<dependency>
    <groupId>sk.annotation.library.jam</groupId>
    <artifactId>jam-common</artifactId>
    <version>${jam.version}</version>
</dependency>

<dependency>
    <groupId>sk.annotation.library.jam</groupId>
    <artifactId>jam-processor</artifactId>
    <scope>provided</scope>
    <version>${jam.version}</version>
</dependency>

How to create a mapper?

Define Mapper interface (or abstract class) describing the mapping you want. Follow example is with Spring support:

@Mapper
@EnableSpring   // this is optional, generated interface is annotated for spring with @Component 
public interface SimpleMapper {
    
    // Imutable mapping
    OutBean map(InBean in);
    
    // Update graph
    OutBean update(InBean in, @Return OutBean out);
}

How to use it?

Getting mapper instance directly:

public class UsingMapper {

    public void main(String[] args) {
        SimpleMapper mapper = MapperUtil.getMapper(SimpleMapper.class);

        // example with immutable mapping
        OutBean res = mapper.map(in);
    }
}

Using mapper in Spring bean:

@Component
public class AnySpringService {
    @Autowired
    private SimpleMapper mapper;

    public void example() {
        // example with immutable mapping
        OutBean res = mapper.map(in);
    
        // example with updating
        OutBean dest = dao.getById(42);
        OutBean res = mapper.update(in, dest);
        // res is the updated bean dest with in values
    }
}

Warning: WEB, documentation, examples and new features are in progress.

Please, follow examples in jam-tests for learn features.

sk.annotation.library.jam

Annotation Slovakia, s. r. o.

Versions

Version
0.9.1