Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/choonchernlim/spring-modularizer

Transforms an input object into a modularized result object based on the requested data module(s).
https://github.com/choonchernlim/spring-modularizer

data-structures design-patterns groovy java-8 spring

Last synced: about 1 month ago
JSON representation

Transforms an input object into a modularized result object based on the requested data module(s).

Awesome Lists containing this project

README

        

# spring-modularizer [![Build Status](https://travis-ci.org/choonchernlim/spring-modularizer.svg?branch=master)](https://travis-ci.org/choonchernlim/spring-modularizer) [![codecov](https://codecov.io/gh/choonchernlim/spring-modularizer/branch/master/graph/badge.svg)](https://codecov.io/gh/choonchernlim/spring-modularizer)

Transforms an input object into a modularized result object based on the requested data module(s).

## Maven Dependency

```xml

com.github.choonchernlim
spring-modularizer
0.1.0

```

## Motivation

To provide an ability to enrich the result object by adding more data modules over time without introducing too many cross cutting concerns.

```text
---------------------------------------------------------------------------------------------------------
INPUT DATA TRANSFORMATION RESULT
---------------------------------------------------------------------------------------------------------
ORM entity, ID, etc. Either cherry-picking from Result object that can be sent back to the
input object or query against user either as object, JSON or XML.
data source(s) to construct The fingerprints allow the user to quickly
requested module(s). determine whether the values have changed
or not.


{
"id": "",
"fingerprint": ""
"a": {
"fingerprint": "",
✓ [ Mapper A ] "prop-1": ...
[ Mapper B ] "prop-2": ...
Input Object ---> ✓ [ Mapper C ] ---> },
[ Mapper D ] "b": null,
[ Mapper ... ] "c": {
[ Mapper Z ] "fingerprint": "",
"prop-3": ...
"prop-4": ...
},
"d": null,
...
}
```

At high level, the code looks something like this:-

```groovy
Set selectedModules = [ SomeModule.A, SomeModule.C ]

SomeEntity entity = // query from DB, etc

// autowired `modularizerService`
SomeResult result = modularizerService.create(entity, selectedModules, SomeResult)
```

## Real World Example

Run `Main.groovy` under ["example" package](src/test/groovy/example) and play around with it.