• Stars
    star
    26
  • Rank 930,752 (Top 19 %)
  • Language
    Java
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Library for converting from one Java class to a dissimilar Java class with similar names based on the Bean convention

Build Status Codacy Badge BCH compliance codecov Maven Central Javadocs Apache 2

Beanmapper

Beanmapper is a Java library for mapping dissimilar Java classes with similar names. The use cases for Beanmapper are the following:

  • mapping from forms to entities, because:
    • for security reasons you want to accept only a limited number of fields as input
    • the form fields are simplified to support frontend processing
  • mapping from entities to results, because:
    • you want to simplify the result for frontend processing
    • you want to expose a limited number of fields for security reasons

Maven dependency

In order to use Beanmapper in your project, simply add the following Maven dependency:

<dependency>
    <groupId>io.beanmapper</groupId>
    <artifactId>beanmapper</artifactId>
    <version>4.1.0</version>
</dependency>

Getting started

You want to map two dissimilar classes with no hierarchical relation (save java.lang.Object), but with a fairly similar naming schema for the fields.

Basic use case for Beanmapper

public class SourceClass {
   public Long id;
   public String name;
   public LocalDate date;
}
public class TargetClass {
   public String name;
   public LocalDate date;
}
BeanMapper beanMapper = new BeanMapper();
SourceClass source = new SourceClass();
source.id = 42L;
source.name = "Henk";
source.date = LocalDate.of(2015, 4, 1));
TargetClass target = beanMapper.map(source, TargetClass.class);

What's more?

The library can help you with the following situations:

  • nested dissimilar classes
  • ignoring parts
  • mapping to fields with other names, even if nested
  • settings defaults if no value is found
  • unwrapping class layers in order to flatten the structure
  • works directly on the bean, no getters/setters required
  • supports a combination of automated and manual processing
  • adding conversion modules for data types

What Beanmapper is not for

Beanmapper is not a library for deep-copying classes. Whenever Beanmapper can get away with a shallow copy, it will do so. Deep-copying is reserved for dissimilar classes.

Want to know more?

Find the rest of the documentation on beanmapper.io.

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

CSVeed

Light-weight, easy-to-use Java-based CSV utility
Java
98
star
2

react-fetch-progressbar

Show a progressbar in React whenever a fetch request is in progress
TypeScript
31
star
3

jarb

JARB - JAva Repository Bridge
Java
28
star
4

spring-boot-docker-postgres

Spring Boot Docker project for running the Postgres container
Java
22
star
5

yml-sorter

Sorts yml files alphabetically
JavaScript
17
star
6

beanmapper-spring

Java
16
star
7

spring-boot-starter-docker

Contains the AutoConfiguration framework for Spring Boot enabled Docker containers
Java
12
star
8

beanmapper-spring-boot-starter

Spring boot starter/autoconfig project for Beanmapper
Java
12
star
9

pdf-library

Toucan-PDF
Java
9
star
10

restzilla

Dynamic REST endpoints for Spring - Convention over configuration
Java
9
star
11

redux-flash-messages

Library for storing flash messages in redux.
TypeScript
8
star
12

easygson

Java wrapper for Gson that allows pure, near-native Json handling
Java
7
star
13

rest-secure-spring-boot-starter

Spring boot autoconfig for spring security in a REST environment
Java
6
star
14

docker-mailhog

MailHog SMTP Server in a Docker container
5
star
15

beanie

Test data generation
Java
5
star
16

database-truncator

Logic for emptying database tables of their content without affecting the structure. Useful for unit tests
Java
5
star
17

ui

UI components as used by 42.nl
TypeScript
4
star
18

mad-spring-connect

Connecting with a Spring REST APIs in a domain friendly manner
TypeScript
4
star
19

seagull-api-wrapper

Wrapper for Insightly REST API
Java
3
star
20

heph

Library for creating smart test-data builders
Java
3
star
21

redux-mad-authentication

A library which stores login credentials in Redux to allow a user to login to a Spring Boot application.
TypeScript
3
star
22

jarb-final-form

Validating forms through JaRB, with react-final-form.
TypeScript
3
star
23

docker-gam

Google Apps Manager in a Docker container
Shell
3
star
24

max-login-attempts-spring-boot-starter

Java
3
star
25

docker-for-mac-workarounds

Various workarounds for Docker for Mac
Shell
2
star
26

quality-workshop-lisa

Quality Workshop for demonstrating the LISA framework in practice
Java
2
star
27

jarb-redux-form

Validating forms through JaRB, with redux-form.
TypeScript
2
star
28

api-key-authentication

Library to easily configure API Key authentication in (parts of) your Spring Boot Application
Java
2
star
29

spring-boot-starter-password-validation

spring-boot-starter-password-validation
Java
2
star
30

responsive-grid-workshop

Workshop over responsive Grid
CSS
1
star
31

spring-test-mvc

Java
1
star
32

fixie

Java
1
star
33

spring-boot-starter-csv

Java
1
star
34

jarb-angular-formly

Makes it easy to create formly forms with jarb validations.
JavaScript
1
star
35

docker-mkosi

mkosi - Create legacy-free OS images
1
star