https://github.com/avides/spring-enricher
Enables simple enriching of objects in spring-projects
https://github.com/avides/spring-enricher
enricher spring spring-boot
Last synced: 2 months ago
JSON representation
Enables simple enriching of objects in spring-projects
- Host: GitHub
- URL: https://github.com/avides/spring-enricher
- Owner: avides
- License: mit
- Created: 2016-03-03T09:35:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-11-14T08:06:19.000Z (over 6 years ago)
- Last Synced: 2025-09-05T09:07:43.260Z (10 months ago)
- Topics: enricher, spring, spring-boot
- Language: Java
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spring-enricher
[](https://maven-badges.herokuapp.com/maven-central/com.avides.spring/spring-enricher)
[](https://github.com/avides/spring-enricher/actions)
[](https://github.com/avides/spring-enricher/actions)
[](https://sonarcloud.io/dashboard?id=avides_spring-enricher)
[](https://sonarcloud.io/dashboard?id=avides_spring-enricher)
[](https://sonarcloud.io/dashboard?id=avides_spring-enricher)
#### Maven
```xml
com.avides.spring
spring-enricher
2.0.0
```
#### Example
```java
@Configuration
@EnableEnriching
public class EnricherConfiguration
{
}
@Service
public class CustomerService
{
@Autowired
private CustomerRepository customerRepository;
@Enriched
public Customer getCustomer(long id)
{
return customerRepository.getCustomer(id);
}
@Enriched
public List getCustomers()
{
return customerRepository.getCustomers();
}
}
@Component
public class CustomerEnricher extends AbstractEnricher
{
@Autowired
private AddressService addressService;
public CustomerEnricher()
{
super(Customer.class);
}
@Override
public void doEnrich(Customer customer)
{
customer.setAddresses(addressService.getAddresses(customer.getId()));
}
}
@Component
public class CustomerOutput
{
@Autowired
private CustomerService customerService;
public void outputCustomers()
{
for (Customer customer : customerService.getCustomers())
{
System.out.println(customer);
}
}
public void outputCustomer(long id)
{
System.out.println(customerService.getCustomer(id));
}
}
```