Posts

Showing posts with the label Lombok

Changing the Default Terminal to Terminator on Ubuntu

Image
Terminator is a powerful tool for developers, allowing you to manage multiple terminal sessions in a single window. Features like splitting panes, tabs, and simultaneous input can significantly boost your productivity. Step 1: Install Terminator First, install Terminator using the apt package manager. sudo apt update sudo apt install terminator -y The -y option automatically answers 'yes' to any prompts during the installation process, streamlining the setup. Step 2: Set as the System Default Ubuntu uses a utility called update-alternatives to manage default applications. We'll use this tool to change the default terminal emulator ( x-terminal-emulator ) to Terminator. Run the Configuration Command Enter the following command in your terminal. A list of available terminals will appear. sudo update-alternatives --config x-terminal-emulator Select Terminator From the resulting list, enter the selection number corresponding to terminator and press Enter. ...

How to Fix Lombok's @Builder Ignoring Initial Values with @Builder.Default

Image
Lombok's @Builder is a powerful feature that replaces repetitive builder pattern code with a single annotation. However, when using @Builder , you might encounter the following warning message when you set an initial value for a field: java: @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. If it is not supposed to be settable during building, make the field final. Why Does the Warning Occur? - How Lombok Works Before solving the problem, it's important to understand why Lombok ignores the initial value of the field. When a class is annotated with @Builder , Lombok generates a separate inner Builder class (e.g., UserBuilder ) at compile time. This is the class we use through the .builder() method. The key is that the fields of the original class and the fields of the Builder class exist in different spaces. import lombok.Builder; import lombok.Getter; @Getter @Builder pu...