Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/publicissapient-france/selma
Selma Java bean mapping that compiles
https://github.com/publicissapient-france/selma
Last synced: 3 months ago
JSON representation
Selma Java bean mapping that compiles
- Host: GitHub
- URL: https://github.com/publicissapient-france/selma
- Owner: publicissapient-france
- License: apache-2.0
- Fork: true (slemesle/selma)
- Created: 2014-01-06T22:14:19.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2020-01-01T15:54:40.000Z (about 5 years ago)
- Last Synced: 2024-08-01T18:24:14.970Z (6 months ago)
- Language: Java
- Homepage: http://selma-java.org
- Size: 2.41 MB
- Stars: 211
- Watchers: 18
- Forks: 38
- Open Issues: 58
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-java - Selma - Annotation processor-based bean mapper. (Projects / Bean Mapping)
- awesome-java-zh - Selma - 基于注释处理器的bean映射器。 (项目 / Bean映射)
- awesome-java - Selma - Annotation processor-based bean mapper. (Projects / Bean Mapping)
README
[![Build Status](https://travis-ci.org/xebia-france/selma.png?branch=master)](https://travis-ci.org/xebia-france/selma)
[![Selma logo](https://raw.github.com/xebia-france/selma/master/resources/logo-v6.png)](http://selma-java.org/)
## 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:```java
@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:
```java
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:
```xml
fr.xebia.extras
selma-processor
1.0
provided
fr.xebia.extras
selma
1.0
```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 :)**