Questions tagged [lombok]
Project Lombok is a tool for reducing boilerplate code in Java through annotations and compile time code generation.
2,060
questions
0
votes
0
answers
10
views
JDBI 3 Nested object with lombok
First of all, I already tried this JDBI 3: Nested SQLObject and it didn't work
I'm trying basically the same thing as the other person, to gather some nested objects in jdbi 3 but using ...
-1
votes
0
answers
26
views
Java Interface vs Final Class for utility classes [duplicate]
What are advantages and disadvantages of the following options to create a file in Java that would only serve as a utility class:
interface with only static methods, vs.
final class with private ...
0
votes
1
answer
18
views
How can I navigate to Lombok generated implementations
I'm wondering if it would be possible to navigate directly to the methods generated by Lombok using Intellij IDEA.
For instance, for this given example:
@Builder
public class AClass {
private ...
0
votes
1
answer
11
views
Can I create a spring-boot webflux server stub with swagger that includes lombok support?
I tried both
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.4.0</version>
&...
0
votes
1
answer
28
views
How to make Data lombok return deep copys of getter method
Spotbugs is giving the following Error warnings:
[ERROR] Medium: MetaData.getCreatedAt() may expose internal representation by returning MetaData.createdAt [...MetaData] At MetaData.java:[line 21] ...
0
votes
0
answers
25
views
Could not resolve Lombok for library
Library Gradle project can't find Lombok dependency.
When I delete Lombok from dependencies all compiled successfully. Perhaps Lombock required some special settings for use in the library?
FAILURE: ...
0
votes
1
answer
17
views
update value by key of json array inside nested json java
I am able to update the value of jsonObject by using key name , here the method which I am using
private static JSONObject setValue(JSONObject json, String key, String newValue) throws JSONException {
...
0
votes
0
answers
21
views
Spring Data JPA projection query with nested constructors does not work with Lombok
I have two nested classes with many fields each (indicated by field1 ... field99). For readability and to force it to fail on adding fields I would like to generate constructors (or builders, if that ...
0
votes
1
answer
39
views
package lombok does not exist Gradle intellij idea
I tried all the mentioned solutions here
lombok doesn't exist
but i couldn't be able to resolve this issue.
I used these dependencies..
compileOnly 'org.projectlombok:lombok:1.18.24'
...
1
vote
1
answer
39
views
Customizing which files are shown in Netbeans' Project View under Project Files
I'm using Netbeans IDE (Version 13) for Java development.
In the projects view Netbeans shows a tab for "Project Files". This usually contains files like pom.xml, settings.xml and nb-...
0
votes
1
answer
67
views
Lombok Nullable value
I have the following code using Lombok:
class Query1 {
@Builder
static class Something{
Inner inner;
public Optional<Inner> getInner() {
return Optional.ofNullable(inner);
...
0
votes
1
answer
30
views
Showing member function as "Not an instance method" [duplicate]
I am working with Sprinboot and tried to access the getter function of the object to get the value. It is showing function name in suggestions
but when using it it is giving the error Not an instance ...
0
votes
2
answers
56
views
Generate json request body using Lombok annotation
I tried multiple pattern , but still no success how can I create JSON Array object with nested JSON object similar like below
{
"deduction": [
{
"id": "50258779&...
0
votes
0
answers
34
views
Add another annotation when an annotation is present with Java 8
I am currently creating my own CRUD-managing class. For this purpose I work with an annotation that looks like this:
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
...
0
votes
0
answers
26
views
Add a object with custom annotation in springboot
I need to add an object like @Slf4j's "log" in a service class, for example:
@Slf4j
@Service
public class MyService {
public void anyMethod() {
log.info("any log");
...
1
vote
1
answer
28
views
Files with the .SCL.lombok extension
When the lombok jar file is opened in Intellij, all files other than the annotations end with .SCL.lombok (e.g. HandleAccessors.SCL.lombok). I was just wondering what the reason for this was and how ...
1
vote
2
answers
31
views
is there a way to create a java class lombok field with a period or other custom character?
How can I make a field name have a period in it? Why? Because this eventually gets translated into JSON that is passed to a service, and the field needs to have a value that is not acceptable as a ...
0
votes
1
answer
27
views
Slf4j logger log fields from parent class
I have following code:
@Slf4j
public class Main {
@Data
public static class AClass {
private String title;
}
@Data
public static class BClass extends AClass {
private Integer amount;
}
...
2
votes
1
answer
45
views
Spring REST + JPA + h2: How to instantiate dummy data for a many to many relationship
I'm trying to build a little project-management tool as my first Spring Boot / JPA / H2 / REST Application using lombok annotations for avoiding boilerplate-code. I followed several promising ...
0
votes
1
answer
83
views
Using both lombok and protobuf results in gradle tasks without dependencies resulting in builds failing sometimes
I use lombok and protobuf simultaneously in gradle. This generates the tasks generateEffectiveLombokConfig and generateProto which are independent. Yet the lombok task should depend on the protobuf ...
0
votes
0
answers
23
views
javadoc generation failed using Spring Auto Rest Docs and lombok
I am using Spring Auto RestDocs and lombok. The gradle configuration looks like this:
dependencies {
jsondoclet 'capital.scalable:spring-auto-restdocs-json-doclet-jdk9:2.0.11'
...
0
votes
1
answer
36
views
How to serialize builder class with inheritance?
I faced a serialization issue of the builder class with inheritance.
It looks like the following:
@Getter
@Setter
public class NumberRuleConfig extends BaseRuleConfig{
private Double min;
...
0
votes
1
answer
26
views
Combining lombok @AllArgsConstructor with Spring-boot MongoDb @PersistenceConstructor
I have a spring-boot application which uses a mongoDb database to store objects. One of the objects is ExampleDoc as below:
package com.example;
import org.springframework.data.annotation.Id;
import ...
0
votes
0
answers
77
views
Lombok works on Liberica JDK 17?
I've been working on a project using BellSoft Liberica JDK v17, IntelliJ 2022.1 and SpringBoot 2.6.7. I have noticed that he has not recognized my entries from Lombok. I have searched for information ...
0
votes
0
answers
25
views
Review pojo java class - What could I make better
I need code review. I've used Lombok and jackson. Static statemts look very "ugly" in Root class. I don't know what I should make with that. Is There another way to create nested classes?
...
0
votes
0
answers
29
views
Not able to mvn install and getting lombokprocessor error
I am trying to build a maven project. The same project is working on my other machine and now I am trying to setup this up on my colleagues machine. When I try to mvn clean install, I get the ...
0
votes
1
answer
29
views
Lombok @Getter and @Setter annotations are not being recognised when getAnnoations() method is used
Lombok @Getter and @Setter annotations are not being recognised when getAnnoations() method is used with a variable by reflection. Any suggestions on how to test if these annoations are present using ...
0
votes
0
answers
23
views
Is lombok val compatible in JSP?
I am using lombok val for defining variables in JSP.
I have tried to import lombok with following statement.
<%@ page import="lombok.val" %>
But when JSP loads on UI it throws below ...
-1
votes
1
answer
21
views
Spring @JsonFormat changing the timezone
I'm sending JSON to a spring app, de-serializing it using @JsonFormat annotations and then returning it to the user. However my input specifically denotes "GMT" but the return data is "...
0
votes
1
answer
39
views
Illegal forward reference while calling one fuction from another function java 11 functional interface
@Getter @Setter
Class Row{
private int position;
private String name;
private List<Column> columns;
}
@Getter @Setter
Class Column{
private int position;
private String name;
...
-1
votes
0
answers
15
views
Is there any way to conditionally populate certain field of class using lombok @Builder [duplicate]
@Builder
class person{
int age
boolean eligible
someMagicFunction(age){
if age> 18 {
eligible = true
}else{
eligible = false
}
}
}
So that I can just pass age and the attribute ...
-1
votes
0
answers
84
views
java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x767018ec)
I'm setting up a project but I'm getting this error in my terminal when I'm trying to run the command " ant clean build" it is showing this error
An annotation processor threw an uncaught ...
1
vote
0
answers
32
views
@JsonAnySetter annotated method sometime gets a value and sometimes get an empty String
I have a collection of PoJos that map the response from an API provided by another team at my company. They have a habit of adding new properties to the json that they send out, without notice. So, ...
0
votes
1
answer
48
views
Java log cannot be resolved
I'm studying a spring project at eclipse IDE.
I met this error 'log cannot be resolved' at all of 'log.info( ... );'
[enter image description here][1]
and these are the solutions I found and worked on ...
-1
votes
1
answer
41
views
IntelliJ / Lombok messing around with "is" prefix and removing it
I have no idea what is happening but for some reason the is prefix from my property is being removed.
I have even removed the annotations from Lombok and manually created the getters and setters but ...
0
votes
1
answer
37
views
How to update any parameter value of existing java lombok Builder object?
If I have a @Builder AnObj,
import lombok.Builder;
@Builder public class AnObj {
private final String name;
private final int age;
}
with its properties (name, age), and there is an ...
0
votes
1
answer
40
views
Cant find Lombok constructor for derived class
I am running into problems using Lombok when I set an enum in the base class.
I have the following code:
@EqualsAndHashCode
@ToString
@Getter
@AllArgsConstructor
@NoArgsConstructor
public abstract ...
0
votes
1
answer
32
views
Why doesn't Lombok Builder work with mutating an existing object?
Why doesn't Lombok Builder work with mutating an existing object?
What if I want to create a partially build object, and then later on update the object with the remaining fields?
Notice that this is ...
3
votes
1
answer
86
views
In Java, is there any way to alias an object field so that it has two names?
I'm getting back into Java programming, and I have a situation where I'd like to do something like this:
public class FieldAliasTest {
static public class Something {
@Alias("...
1
vote
1
answer
36
views
Why does Jackson not require all classes to include @NoArgsConstructor when deserializing?
I'm parsing json and have a class that has a parameter of another class type:
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Vehicle {
...
@JsonProperty("vehicle_info&...
0
votes
1
answer
39
views
JAP: table column with name id but not primary key
I have a table with the columns vendorid and id (and more, omitted here; using lombok for definition):
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "vendor_store&...
0
votes
1
answer
88
views
@Builder(toBuilder = true) on constructor: Error "has private access"
I have the following 2 parent-child classes..
@AllArgsConstructor
public abstract class Data {
@Getter
private final String name;
@Getter
private final String source;
@Getter
...
0
votes
2
answers
56
views
Gradle cannot build lombok annotated class
I had changed my project from maven to gradle. but I had error with this command
./gradlew build --scan
for project that has lombok in it.
I've tried all method from online an it is useless. The ...
0
votes
0
answers
71
views
Using Lombok's @SuperBuilder with GSON's fromJson throws nullPointerException parsing JSON in a complex inheritance structure
Inheritance structure is as follows:
Child > Parent > SuperParentBuilderEnabler > (3rd party) RecursiveTreeObject<Parent>
Using Gson's fromJson(obj, Child.class);
function works fine ...
0
votes
0
answers
133
views
Error: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
I'm using spring boot (2.0.5 RELEASE), H2 DB, Lombok and Java 1.8. I've configured a basic entity using spring data jpa. I'm getting the below exception while trying to run the app. My local machine ...
0
votes
1
answer
84
views
Spring Constructor without Id field
I want to create a constructor for more entities, but without the Id field. What do you recommend me to do? @AllArgsConstructor annotation is not good because then Id field would be included, @...
1
vote
0
answers
53
views
Lombok @EqualsAndHashcode
I am implementing Lombok @EqualsAndHashcode annotation. I need to control order of parameters included in hashCode() generation. For example Lombok generates this:
public int hashCode() {
final ...
0
votes
0
answers
87
views
JaCoCo test coverage issue maven build failing
I'm facing the below issue,
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project VstsReport: An Ant BuildException has occured: Error while creating ...
0
votes
1
answer
54
views
Map fields with the same name using Lombok
I'm using Lombok in a Spring Boot application, The MongoDB object are the same as my domain model so when I do the mapping I have to specify all the field names even they are the same
public static ...
-2
votes
2
answers
94
views
When I installed lombok version 1.18.22 in eclipse, then I cant rename files [closed]
When I installed lombok version 1.18.22 in eclipse 2022-03, then I cant rename files (alt+shift+R)
desired behavior: Need to rename variable in eclipse (java file)
error: I cant rename variables in ...