> For the complete documentation index, see [llms.txt](https://divine.qibergames.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://divine.qibergames.com/best-practices/using-lombok.md).

# Using lombok

Although DiVine removes a huge chunk of boilerplate code that would be used for your initialization processes. Your getters, setters and constructors could still take up a lot of space. It is generally recommended to use [Lombok](https://projectlombok.org/) to get rid of those code overheads from the source code.

```java
@Service
@Getter
class MinigameManager {
    private final List<Minigame> minigames = new ArrayList<>();
    
    @Inject
    private NetworkManager networkManager;
    
    // ... bunch of other fields
}
```

```java
@Service
@RequiredArgsConstructor
class UserController {
    @Inject
    private final UserRepository repository;
    
    @Inject(token = "API_TOKEN")
    private final String apiToken;
    
    @AfterInitialized
    public void init() {
        repository.login(apiToken, Scope.READ | Scope.WRITE);
    }
}
```

{% hint style="info" %}
The code above will generate a constructor for `UserController`, which will take in `repository` and `apiToken` as parameters. This will be fully compatible with DiVine.
{% endhint %}

```java
@RequiredArgsConstructor(onConstructor_ = @ConstructWith)
class SessionManager {
    @Inject
    private final SessionCache cache;
    
    public SessionManager() {
        cache = SessionCache.newEmptyCache();
    }
}
```

{% hint style="info" %}
Your code might need multiple constructors, where DiVine should use a generated one. You can still put `@ConstructWith` on these generated constructors.
{% endhint %}

```java
@Service
@ToString
class DatabaseCredentials {
    private final String database, username, password;
}
```

```java
@Service
public class ConnectionHandler {
    @Inject
    private @NotNull PacketCodec codec;
    
    @Inject(token = "PROTOCOL_VERSION")
    private int protocolVersion;
    
    public void sendHandshake(@NotNull Node node) {
        node.queue(codec.encode(Packet.HANDSHAKE, protocolVersion));
        node.queue(codec.encode(Packet.MESSAGE, "Hello, World"));
        node.flush();
    }
}
```

{% hint style="info" %}
You may explicitly specify null assertations for your injected fields. DiVine will guarantee to always create an instance for your services.
{% endhint %}
