Skip to content

Commit aa7262b

Browse files
committed
Delombok code.
Closes #2286
1 parent 18030f9 commit aa7262b

File tree

38 files changed

+989
-231
lines changed

38 files changed

+989
-231
lines changed

lombok.config

Lines changed: 0 additions & 2 deletions
This file was deleted.

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@
133133
<version>${hamcrest}</version>
134134
<scope>test</scope>
135135
</dependency>
136-
137136
</dependencies>
138137

139138
<repositories>

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/UriToEntityConverterUnitTests.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import static org.assertj.core.api.Assertions.*;
1919
import static org.mockito.Mockito.*;
2020

21-
import lombok.Value;
22-
2321
import java.net.URI;
2422
import java.util.List;
2523
import java.util.Optional;
@@ -49,6 +47,7 @@
4947
import org.springframework.data.util.Streamable;
5048
import org.springframework.data.util.TypeInformation;
5149
import org.springframework.format.support.DefaultFormattingConversionService;
50+
import org.springframework.util.ObjectUtils;
5251

5352
/**
5453
* Unit tests for {@link UriToEntityConverter}.
@@ -197,9 +196,37 @@ public JMoleculesIdentifier getId() {
197196
return JMoleculesIdentifier.of(UUID.randomUUID());
198197
}
199198

200-
@Value(staticConstructor = "of")
201-
static class JMoleculesIdentifier implements Identifier {
202-
UUID id;
199+
static final class JMoleculesIdentifier implements Identifier {
200+
private final UUID id;
201+
202+
private JMoleculesIdentifier(UUID id) {
203+
this.id = id;
204+
}
205+
206+
public static JMoleculesIdentifier of(UUID id) {
207+
return new JMoleculesIdentifier(id);
208+
}
209+
210+
public UUID getId() {
211+
return this.id;
212+
}
213+
214+
@Override
215+
public boolean equals(Object o) {
216+
if (this == o)
217+
return true;
218+
if (o == null || getClass() != o.getClass())
219+
return false;
220+
221+
JMoleculesIdentifier that = (JMoleculesIdentifier) o;
222+
223+
return ObjectUtils.nullSafeEquals(id, that.id);
224+
}
225+
226+
@Override
227+
public int hashCode() {
228+
return ObjectUtils.nullSafeHashCode(id);
229+
}
203230
}
204231
}
205232

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/Order.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package org.springframework.data.rest.core.domain;
1717

18-
import lombok.Value;
19-
2018
import java.util.UUID;
2119

2220
import org.springframework.data.annotation.Id;
@@ -25,9 +23,20 @@
2523
/**
2624
* @author Oliver Gierke
2725
*/
28-
@Value
29-
class Order {
26+
final class Order {
27+
28+
@Id private final UUID id = UUID.randomUUID();
29+
@Reference private final Person creator;
30+
31+
public Order(Person creator) {
32+
this.creator = creator;
33+
}
34+
35+
public UUID getId() {
36+
return this.id;
37+
}
3038

31-
@Id UUID id = UUID.randomUUID();
32-
@Reference Person creator;
39+
public Person getCreator() {
40+
return this.creator;
41+
}
3342
}

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/Person.java

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,14 @@
1515
*/
1616
package org.springframework.data.rest.core.domain;
1717

18-
import lombok.AccessLevel;
19-
import lombok.Data;
20-
import lombok.RequiredArgsConstructor;
21-
2218
import java.util.ArrayList;
2319
import java.util.Calendar;
2420
import java.util.Date;
2521
import java.util.List;
2622
import java.util.UUID;
2723

2824
import org.springframework.data.annotation.Id;
29-
import org.springframework.data.annotation.PersistenceConstructor;
25+
import org.springframework.data.annotation.PersistenceCreator;
3026
import org.springframework.data.annotation.Reference;
3127
import org.springframework.data.rest.core.annotation.RestResource;
3228

@@ -36,8 +32,6 @@
3632
* @author Jon Brisbin
3733
* @author Oliver Gierke
3834
*/
39-
@Data
40-
@RequiredArgsConstructor(access = AccessLevel.PRIVATE, onConstructor = @__(@PersistenceConstructor))
4135
public class Person {
4236

4337
private final @Id UUID id;
@@ -51,8 +45,51 @@ public Person(String firstName, String lastName) {
5145
private @RestResource(path = "father-mapped") @Reference Person father;
5246
private Date created = Calendar.getInstance().getTime();
5347

48+
@PersistenceCreator
49+
private Person(UUID id, String firstName, String lastName) {
50+
this.id = id;
51+
this.firstName = firstName;
52+
this.lastName = lastName;
53+
}
54+
5455
public Person addSibling(Person p) {
5556
siblings.add(p);
5657
return this;
5758
}
59+
60+
public UUID getId() {
61+
return this.id;
62+
}
63+
64+
public String getFirstName() {
65+
return this.firstName;
66+
}
67+
68+
public String getLastName() {
69+
return this.lastName;
70+
}
71+
72+
public List<Person> getSiblings() {
73+
return this.siblings;
74+
}
75+
76+
public Person getFather() {
77+
return this.father;
78+
}
79+
80+
public Date getCreated() {
81+
return this.created;
82+
}
83+
84+
public void setSiblings(List<Person> siblings) {
85+
this.siblings = siblings;
86+
}
87+
88+
public void setFather(Person father) {
89+
this.father = father;
90+
}
91+
92+
public void setCreated(Date created) {
93+
this.created = created;
94+
}
5895
}

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/Profile.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
*/
1616
package org.springframework.data.rest.core.domain;
1717

18-
import lombok.Value;
19-
import lombok.experimental.NonFinal;
20-
2118
import java.util.UUID;
2219

2320
import org.springframework.data.annotation.Id;
@@ -26,10 +23,25 @@
2623
* @author Jon Brisbin
2724
* @author Oliver Gierke
2825
*/
29-
@NonFinal
30-
@Value
3126
public class Profile {
3227

33-
@Id UUID id = UUID.randomUUID();
34-
String name, type;
28+
@Id private final UUID id = UUID.randomUUID();
29+
private final String name, type;
30+
31+
public Profile(String name, String type) {
32+
this.name = name;
33+
this.type = type;
34+
}
35+
36+
public UUID getId() {
37+
return this.id;
38+
}
39+
40+
public String getName() {
41+
return this.name;
42+
}
43+
44+
public String getType() {
45+
return this.type;
46+
}
3547
}

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/ResourceStringUtilsTests.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
import static org.assertj.core.api.Assertions.*;
1919

20-
import lombok.Value;
21-
2220
import java.util.stream.Stream;
2321

2422
import org.junit.jupiter.api.DynamicTest;
@@ -34,36 +32,31 @@ class ResourceStringUtilsTests {
3432
@TestFactory
3533
Stream<DynamicTest> shouldDetectTextPresence() {
3634

37-
return DynamicTest.stream(fixtures(), Fixture::getName, it -> {
38-
assertThat(ResourceStringUtils.hasTextExceptSlash(it.getActual())).isEqualTo(it.hasText);
35+
return DynamicTest.stream(fixtures(), Fixture::name, it -> {
36+
assertThat(ResourceStringUtils.hasTextExceptSlash(it.actual())).isEqualTo(it.hasText);
3937
});
4038
}
4139

4240
@TestFactory
4341
Stream<DynamicTest> shouldRemoveLeadingSlashIfAny() {
4442

45-
return DynamicTest.stream(fixtures(), Fixture::getName, it -> {
46-
assertThat(ResourceStringUtils.removeLeadingSlash(it.getActual())).isEqualTo(it.getExpected());
43+
return DynamicTest.stream(fixtures(), Fixture::name, it -> {
44+
assertThat(ResourceStringUtils.removeLeadingSlash(it.actual())).isEqualTo(it.expected());
4745
});
4846
}
4947

5048
static Stream<Fixture> fixtures() {
5149

52-
return Stream.of(
53-
Fixture.of("empty string has no text and should remain empty", "", "", false),
54-
Fixture.of("blank string has no text and should remain as is", " ", " ", false),
55-
Fixture.of("string made of only a leading slash has no text and should be returned empty", "/", "", false),
56-
Fixture.of("blank string with only slashes has no text and should be returned as is", " / ", " / ",
50+
return Stream.of(new Fixture("empty string has no text and should remain empty", "", "", false),
51+
new Fixture("blank string has no text and should remain as is", " ", " ", false),
52+
new Fixture("string made of only a leading slash has no text and should be returned empty", "/", "", false),
53+
new Fixture("blank string with only slashes has no text and should be returned as is", " / ", " / ",
5754
false),
58-
Fixture.of("normal string has text and should be returned as such", "hello", "hello", true),
59-
Fixture.of("normal string with leading slash has text and should be returned without leading slash", "/hello",
55+
new Fixture("normal string has text and should be returned as such", "hello", "hello", true),
56+
new Fixture("normal string with leading slash has text and should be returned without leading slash", "/hello",
6057
"hello", true));
6158
}
6259

63-
@Value(staticConstructor = "of")
64-
static class Fixture {
65-
66-
String name, actual, expected;
67-
boolean hasText;
60+
record Fixture(String name, String actual, String expected, boolean hasText) {
6861
}
6962
}

spring-data-rest-tests/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@
3939
<version>${groovy.version}</version>
4040
</dependency>
4141

42-
<dependency>
43-
<groupId>org.projectlombok</groupId>
44-
<artifactId>lombok</artifactId>
45-
<version>${lombok}</version>
46-
<scope>provided</scope>
47-
</dependency>
48-
4942
</dependencies>
5043

5144
</project>

spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Book.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
import jakarta.persistence.GeneratedValue;
2222
import jakarta.persistence.Id;
2323
import jakarta.persistence.ManyToMany;
24-
import lombok.AllArgsConstructor;
25-
import lombok.Getter;
26-
import lombok.NoArgsConstructor;
2724

2825
import java.util.HashSet;
2926
import java.util.Set;
@@ -68,13 +65,33 @@ public Book(String isbn, String title, long soldUnits, Iterable<Author> authors,
6865
this.offer = offer;
6966
}
7067

71-
@Getter
7268
@Embeddable
73-
@AllArgsConstructor
74-
@NoArgsConstructor
7569
static class Offer {
7670

7771
double price;
7872
String currency;
73+
74+
public Offer(double price, String currency) {
75+
this.price = price;
76+
this.currency = currency;
77+
}
78+
79+
public Offer() {}
80+
81+
public double getPrice() {
82+
return price;
83+
}
84+
85+
public void setPrice(double price) {
86+
this.price = price;
87+
}
88+
89+
public String getCurrency() {
90+
return currency;
91+
}
92+
93+
public void setCurrency(String currency) {
94+
this.currency = currency;
95+
}
7996
}
8097
}

spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Category.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import jakarta.persistence.GeneratedValue;
2020
import jakarta.persistence.Id;
2121
import jakarta.persistence.Version;
22-
import lombok.Data;
2322

2423
/**
2524
* @author Dario Seidl
2625
*/
27-
@Data
2826
@Entity
2927
class Category {
3028

@@ -38,4 +36,28 @@ private Category() {}
3836
public Category(String name) {
3937
this.name = name;
4038
}
39+
40+
public Long getId() {
41+
return this.id;
42+
}
43+
44+
public Long getVersion() {
45+
return this.version;
46+
}
47+
48+
public String getName() {
49+
return this.name;
50+
}
51+
52+
public void setId(Long id) {
53+
this.id = id;
54+
}
55+
56+
public void setVersion(Long version) {
57+
this.version = version;
58+
}
59+
60+
public void setName(String name) {
61+
this.name = name;
62+
}
4163
}

0 commit comments

Comments
 (0)