Skip to content

rpridal/J8Mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

J8Mapper

Generic simply cleary mapper

##Usage: ###Simple mapping

Target target = MapperBuilder.start(Source.class, Target.class)
                .addMapping(Source::getS, Target::setT)
                .addMapping(Source::getI, Target::setI)
                .build()
                .map(s, Target::new);

###Collection mapping

List<Target> mapList = MapperBuilder.start(Source.class, Target.class)
                .addMapping(Source::getS, Target::setT)
                .addMapping(Source::getI, Target::setI)
                .build()
                .map(source, Target::new)
                .collect(Collectors.toList());

###Static value mapping

Target target = MapperBuilder.start(Source.class, Target.class)
                .addMapping(Source::getS, Target::setT)
                .addMapping(10, Target::setI)
                .build()
                .map(s, Target::new);

###Mapping calculation

Target target = MapperBuilder.start(Source.class, Target.class)
                .addMapping(Source::getS, Target::setT)
                .addMapping(s -> s.getI() + 10, Target::setI)
                .build()
                .map(source, Target::new);

###Mapping via mapper

Mapper<Source, Target> mapper = MapperBuilder.start(Source.class, Target.class)
                .addMapping(Source::getS, Target::setT)
                .addMapping(Source::getI, Target::setI)
                .build();
...
Target target = mapper.map(s, Target::new);

About

Generic simply cleary mapper

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages