Skip to content

Commit

Permalink
Use Lombok and Guice to remove some boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
i3ats committed Aug 26, 2024
1 parent e0069e0 commit 28200ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@

import com.google.auto.service.AutoService;
import jakarta.inject.Inject;
import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* Concrete implementation of the SomeService interface.
*/
@RequiredArgsConstructor(onConstructor = @__(@Inject))
public class SomeServiceImpl implements SomeService {

private static final Logger LOGGER = LogManager.getLogger();

private final AnotherService anotherService;

@Inject
SomeServiceImpl(AnotherService anotherService) {
this.anotherService = anotherService;
}


@Override
public void performService() {
LOGGER.info("Performing Service");
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/joevno/exampleproject/MyService.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package com.joevno.exampleproject;

import jakarta.inject.Inject;
import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* This class is a simple service that logs a message.
*/
@RequiredArgsConstructor(onConstructor = @__(@Inject))
class MyService {
private static final Logger LOGGER = LogManager.getLogger();
private final SomeService someService;

@Inject
MyService(SomeService someService) {
this.someService = someService;
}

void performService() {
LOGGER.info("Performing Service");
someService.performService();
Expand Down

0 comments on commit 28200ec

Please sign in to comment.