> 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://divine.qibergames.com/best-practices/using-lombok.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
