fr.xebia.extras:selma-processor

Contains the annotation processor for Selma used to generate code at compile time

License

License

Categories

Categories

Selma General Purpose Libraries Bean Mapping
GroupId

GroupId

fr.xebia.extras
ArtifactId

ArtifactId

selma-processor
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Contains the annotation processor for Selma used to generate code at compile time

Download selma-processor

How to add to project

<!-- https://jarcasting.com/artifacts/fr.xebia.extras/selma-processor/ -->
<dependency>
    <groupId>fr.xebia.extras</groupId>
    <artifactId>selma-processor</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/fr.xebia.extras/selma-processor/
implementation 'fr.xebia.extras:selma-processor:1.0'
// https://jarcasting.com/artifacts/fr.xebia.extras/selma-processor/
implementation ("fr.xebia.extras:selma-processor:1.0")
'fr.xebia.extras:selma-processor:jar:1.0'
<dependency org="fr.xebia.extras" name="selma-processor" rev="1.0">
  <artifact name="selma-processor" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.xebia.extras', module='selma-processor', version='1.0')
)
libraryDependencies += "fr.xebia.extras" % "selma-processor" % "1.0"
[fr.xebia.extras/selma-processor "1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
fr.xebia.extras : selma jar 1.0
com.squareup : javawriter jar 2.5.0

test (11)

Group / Artifact Type Version
org.springframework : spring-core jar 4.1.6.RELEASE
junit : junit jar 4.12
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-library jar 1.3
org.mockito : mockito-all jar 1.9.5
org.springframework : spring-context jar 4.1.6.RELEASE
org.apache.geronimo.specs : geronimo-atinject_1.0_spec jar 1.0
org.apache.geronimo.specs : geronimo-jcdi_1.1_spec jar 1.0
org.apache.geronimo.specs : geronimo-interceptor_1.2_spec jar 1.0
org.apache.openwebbeans : openwebbeans-impl jar 1.5.0
org.assertj : assertj-core jar 1.7.0

Project Modules

There are no modules declared in this project.

Build Status

Selma logo

Selma Java bean mapping at compile time !

What is Selma ?

S3lm4 say Selma, stands for Stupid Simple Statically Linked Mapper. In fact it is on one side an Annotation Processor that generate Java code to handle the mapping from field to field at compile time. On the other side, it is a Runtime library to instantiate and invoke the generated Mapper.

How does it work ?

First add selma-processor as a provided dependency and selma as a compile dependency to your build. Then, define a Mapper interface describing the mapping you want:

@Mapper
public interface SelmaMapper {

    // Imutable mapping
    OutBean asOutBean(InBean source);

    // Update graph
    OutBean updateOutBean(InBean source, OutBean destination);

}

Then ? Well just use the generated Mapper:

    SelmaMapper mapper = Selma.mapper(SelmaMapper.class);

    OutBean res = mapper.asOutBean(in);

    // Or
    OutBean dest = dao.getById(42);

    OutBean res = mapper.updateOutBean(in, dest);
    // res is the updated bean dest with in values

And voilà !

Visit our site: (http://selma-java.org)

Features

  • Generate code for mapping bean to bean matching fields to fields ** Support for nested bean ** Bean should respect Java property convention
  • Custom field to (embedded)field name mapping
  • Maps Enum using identical values with default value
  • Maps Collection any to any
  • Maps Map any to any
  • Use strict memory duplication for all fields except immutables
  • Support for SourcedBeans to instantiate beans is out of the box
  • Support Type to Type custom mapping using custom mapping methods
  • Gives full feedback at compilation time
  • Break build when mapping does not work Say good bye to mapping errors in production

Usage

First add selma and selma-processor to your pom dependencies:

        <!-- scope provided because the processor is only needed for the compiler -->
        <dependency>
            <groupId>fr.xebia.extras</groupId>
            <artifactId>selma-processor</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- This is the only real dependency you will have in your binaries -->
        <dependency>
            <groupId>fr.xebia.extras</groupId>
            <artifactId>selma</artifactId>
            <version>1.0</version>
        </dependency>

Then, as I said earlier, build your interface with @Mapper annotation and enjoy.

Checkout the example module to have a deeper look.

Help needed, please report issues and ask for features :)

fr.xebia.extras

Publicis Sapient Engineering

Communauté Tech de Publicis Sapient, nous créons des logiciels de haute qualité. Nos terrains de jeu : Data, Cloud, Dev front, back, mobile, Coaching agile

Versions

Version
1.0
0.15
0.14
0.13
0.12
0.11
0.10
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1