diff --git a/pom.xml b/pom.xml
index 191786d37..4e95887e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -226,6 +226,22 @@
test
+
+
+ org.projectlombok
+ lombok
+ 999999
+ test
+
+
org.apache.openwebbeans.test
cditest-owb
@@ -435,6 +451,12 @@
spring-libs-snapshot
https://repo.spring.io/libs-snapshot
+
+
+ local-maven-repo
+ file:///${project.basedir}/src/test/resources/local-maven-repo
+
+
diff --git a/src/test/java/org/springframework/data/elasticsearch/NestedObjectTests.java b/src/test/java/org/springframework/data/elasticsearch/NestedObjectTests.java
index 905510aad..6cc24ff90 100644
--- a/src/test/java/org/springframework/data/elasticsearch/NestedObjectTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/NestedObjectTests.java
@@ -19,10 +19,6 @@ import static org.assertj.core.api.Assertions.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
-import lombok.Data;
-import lombok.Getter;
-import lombok.Setter;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -53,6 +49,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.data.elasticsearch.utils.IndexInitializer;
+import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
/**
@@ -384,82 +381,238 @@ public class NestedObjectTests {
assertThat(books.getSearchHit(0).getContent().getId()).isEqualTo(book2.getId());
}
- @Setter
- @Getter
@Document(indexName = "test-index-book-nested-objects", replicas = 0, refreshInterval = "-1")
static class Book {
- @Id private String id;
- private String name;
- @Field(type = FieldType.Object) private Author author;
- @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>();
- @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
+ @Nullable @Id private String id;
+ @Nullable private String name;
+ @Nullable @Field(type = FieldType.Object) private Author author;
+ @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>();
+ @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
searchAnalyzer = "standard") }) private String description;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
+
+ @Nullable
+ public Author getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(@Nullable Author author) {
+ this.author = author;
+ }
+
+ @Nullable
+ public Map> getBuckets() {
+ return buckets;
+ }
+
+ public void setBuckets(@Nullable Map> buckets) {
+ this.buckets = buckets;
+ }
+
+ @Nullable
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(@Nullable String description) {
+ this.description = description;
+ }
}
- @Data
@Document(indexName = "test-index-person", replicas = 0, refreshInterval = "-1")
static class Person {
+ @Nullable @Id private String id;
+ @Nullable private String name;
+ @Nullable @Field(type = FieldType.Nested) private List car;
+ @Nullable @Field(type = FieldType.Nested, includeInParent = true) private List books;
- @Id private String id;
+ @Nullable
+ public String getId() {
+ return id;
+ }
- private String name;
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
- @Field(type = FieldType.Nested) private List car;
+ @Nullable
+ public String getName() {
+ return name;
+ }
- @Field(type = FieldType.Nested, includeInParent = true) private List books;
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
+
+ @Nullable
+ public List getCar() {
+ return car;
+ }
+
+ public void setCar(@Nullable List car) {
+ this.car = car;
+ }
+
+ @Nullable
+ public List getBooks() {
+ return books;
+ }
+
+ public void setBooks(@Nullable List books) {
+ this.books = books;
+ }
}
- @Data
static class Car {
+ @Nullable private String name;
+ @Nullable private String model;
- private String name;
- private String model;
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Nullable
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
}
- /**
- * @author Rizwan Idrees
- * @author Mohsin Husen
- * @author Artur Konczak
- */
- @Data
@Document(indexName = "test-index-person-multiple-level-nested", replicas = 0, refreshInterval = "-1")
static class PersonMultipleLevelNested {
+ @Nullable @Id private String id;
+ @Nullable private String name;
+ @Nullable @Field(type = FieldType.Nested) private List girlFriends;
+ @Nullable @Field(type = FieldType.Nested) private List cars;
+ @Nullable @Field(type = FieldType.Nested, includeInParent = true) private List bestCars;
- @Id private String id;
+ @Nullable
+ public String getId() {
+ return id;
+ }
- private String name;
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
- @Field(type = FieldType.Nested) private List girlFriends;
+ @Nullable
+ public String getName() {
+ return name;
+ }
- @Field(type = FieldType.Nested) private List cars;
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
- @Field(type = FieldType.Nested, includeInParent = true) private List bestCars;
+ @Nullable
+ public List getGirlFriends() {
+ return girlFriends;
+ }
+
+ public void setGirlFriends(@Nullable List girlFriends) {
+ this.girlFriends = girlFriends;
+ }
+
+ @Nullable
+ public List getCars() {
+ return cars;
+ }
+
+ public void setCars(@Nullable List cars) {
+ this.cars = cars;
+ }
+
+ @Nullable
+ public List getBestCars() {
+ return bestCars;
+ }
+
+ public void setBestCars(@Nullable List bestCars) {
+ this.bestCars = bestCars;
+ }
}
- /**
- * @author Mohsin Husen
- */
- @Data
static class GirlFriend {
+ @Nullable private String name;
+ @Nullable private String type;
+ @Nullable @Field(type = FieldType.Nested) private List cars;
- private String name;
+ @Nullable
+ public String getName() {
+ return name;
+ }
- private String type;
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
- @Field(type = FieldType.Nested) private List cars;
+ @Nullable
+ public String getType() {
+ return type;
+ }
+
+ public void setType(@Nullable String type) {
+ this.type = type;
+ }
+
+ @Nullable
+ public List getCars() {
+ return cars;
+ }
+
+ public void setCars(@Nullable List cars) {
+ this.cars = cars;
+ }
}
- /**
- * @author Rizwan Idrees
- * @author Mohsin Husen
- */
- @Data
static class Author {
+ @Nullable private String id;
+ @Nullable private String name;
- private String id;
- private String name;
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/annotations/ComposableAnnotationsUnitTest.java b/src/test/java/org/springframework/data/elasticsearch/annotations/ComposableAnnotationsUnitTest.java
index 645dfdeea..dc468eb90 100644
--- a/src/test/java/org/springframework/data/elasticsearch/annotations/ComposableAnnotationsUnitTest.java
+++ b/src/test/java/org/springframework/data/elasticsearch/annotations/ComposableAnnotationsUnitTest.java
@@ -18,10 +18,6 @@ package org.springframework.data.elasticsearch.annotations;
import static org.assertj.core.api.Assertions.*;
import static org.skyscreamer.jsonassert.JSONAssert.*;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
@@ -41,6 +37,7 @@ import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersiste
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity;
+import org.springframework.lang.Nullable;
/**
* @author Peter-Josef Meisch
@@ -144,14 +141,47 @@ public class ComposableAnnotationsUnitTest {
public @interface TextKeywordField {
}
- @Data
- @NoArgsConstructor
- @AllArgsConstructor
@DocumentNoCreate(indexName = "test-no-create")
static class ComposedAnnotationEntity {
- @Id private String id;
- @NullValueField(name = "null-value") private String nullValue;
- @LocalDateField private LocalDate theDate;
- @TextKeywordField private String multiField;
+ @Nullable @Id private String id;
+ @Nullable @NullValueField(name = "null-value") private String nullValue;
+ @Nullable @LocalDateField private LocalDate theDate;
+ @Nullable @TextKeywordField private String multiField;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getNullValue() {
+ return nullValue;
+ }
+
+ public void setNullValue(@Nullable String nullValue) {
+ this.nullValue = nullValue;
+ }
+
+ @Nullable
+ public LocalDate getTheDate() {
+ return theDate;
+ }
+
+ public void setTheDate(@Nullable LocalDate theDate) {
+ this.theDate = theDate;
+ }
+
+ @Nullable
+ public String getMultiField() {
+ return multiField;
+ }
+
+ public void setMultiField(@Nullable String multiField) {
+ this.multiField = multiField;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/client/reactive/ReactiveElasticsearchClientIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/client/reactive/ReactiveElasticsearchClientIntegrationTests.java
index d4aafe4e6..eea2e77a8 100644
--- a/src/test/java/org/springframework/data/elasticsearch/client/reactive/ReactiveElasticsearchClientIntegrationTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/client/reactive/ReactiveElasticsearchClientIntegrationTests.java
@@ -17,7 +17,6 @@ package org.springframework.data.elasticsearch.client.reactive;
import static org.assertj.core.api.Assertions.*;
-import lombok.SneakyThrows;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -1112,7 +1111,6 @@ public class ReactiveElasticsearchClientIntegrationTests {
.create(true);
}
- @SneakyThrows
private String doIndex(Map source, String index) {
return operations.save(source, IndexCoordinates.of(index)).block().get("id").toString();
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/config/nested/EnableNestedElasticsearchRepositoriesTests.java b/src/test/java/org/springframework/data/elasticsearch/config/nested/EnableNestedElasticsearchRepositoriesTests.java
index 098e9d0d5..47a7d73a9 100644
--- a/src/test/java/org/springframework/data/elasticsearch/config/nested/EnableNestedElasticsearchRepositoriesTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/config/nested/EnableNestedElasticsearchRepositoriesTests.java
@@ -18,9 +18,6 @@ package org.springframework.data.elasticsearch.config.nested;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
-import lombok.Builder;
-import lombok.Data;
-
import java.lang.Double;
import java.lang.Long;
@@ -41,6 +38,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTem
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.repository.Repository;
+import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
/**
@@ -75,20 +73,17 @@ public class EnableNestedElasticsearchRepositoriesTests {
assertThat(nestedRepository).isNotNull();
}
- @Data
- @Builder
@Document(indexName = "test-index-sample-config-nested", replicas = 0, refreshInterval = "-1")
static class SampleEntity {
-
- @Id private String id;
- @Field(type = Text, store = true, fielddata = true) private String type;
- @Field(type = Text, store = true, fielddata = true) private String message;
- private int rate;
- @ScriptedField private Double scriptedRate;
- private boolean available;
- private String highlightedMessage;
- private GeoPoint location;
- @Version private Long version;
+ @Nullable @Id private String id;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String type;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String message;
+ @Nullable private int rate;
+ @Nullable @ScriptedField private Double scriptedRate;
+ @Nullable private boolean available;
+ @Nullable private String highlightedMessage;
+ @Nullable private GeoPoint location;
+ @Nullable @Version private Long version;
}
interface SampleRepository extends Repository {}
diff --git a/src/test/java/org/springframework/data/elasticsearch/config/notnested/EnableElasticsearchRepositoriesTests.java b/src/test/java/org/springframework/data/elasticsearch/config/notnested/EnableElasticsearchRepositoriesTests.java
index 8e167a6ac..c089210c7 100644
--- a/src/test/java/org/springframework/data/elasticsearch/config/notnested/EnableElasticsearchRepositoriesTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/config/notnested/EnableElasticsearchRepositoriesTests.java
@@ -18,8 +18,6 @@ package org.springframework.data.elasticsearch.config.notnested;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
-import lombok.Data;
-
import java.lang.Double;
import java.lang.Long;
import java.util.UUID;
@@ -122,33 +120,187 @@ public class EnableElasticsearchRepositoriesTests implements ApplicationContextA
assertThat(nestedRepository).isNull();
}
- @Data
@Document(indexName = "test-index-sample-config-not-nested", replicas = 0, refreshInterval = "-1")
static class SampleEntity {
+ @Nullable @Id private String id;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String type;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String message;
+ @Nullable private int rate;
+ @Nullable @ScriptedField private Double scriptedRate;
+ @Nullable private boolean available;
+ @Nullable private String highlightedMessage;
+ @Nullable private GeoPoint location;
+ @Nullable @Version private Long version;
- @Id private String id;
- @Field(type = Text, store = true, fielddata = true) private String type;
- @Field(type = Text, store = true, fielddata = true) private String message;
- private int rate;
- @ScriptedField private Double scriptedRate;
- private boolean available;
- private String highlightedMessage;
- private GeoPoint location;
- @Version private Long version;
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getType() {
+ return type;
+ }
+
+ public void setType(@Nullable String type) {
+ this.type = type;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ public int getRate() {
+ return rate;
+ }
+
+ public void setRate(int rate) {
+ this.rate = rate;
+ }
+
+ @Nullable
+ public java.lang.Double getScriptedRate() {
+ return scriptedRate;
+ }
+
+ public void setScriptedRate(@Nullable java.lang.Double scriptedRate) {
+ this.scriptedRate = scriptedRate;
+ }
+
+ public boolean isAvailable() {
+ return available;
+ }
+
+ public void setAvailable(boolean available) {
+ this.available = available;
+ }
+
+ @Nullable
+ public String getHighlightedMessage() {
+ return highlightedMessage;
+ }
+
+ public void setHighlightedMessage(@Nullable String highlightedMessage) {
+ this.highlightedMessage = highlightedMessage;
+ }
+
+ @Nullable
+ public GeoPoint getLocation() {
+ return location;
+ }
+
+ public void setLocation(@Nullable GeoPoint location) {
+ this.location = location;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
}
- @Data
@Document(indexName = "test-index-uuid-keyed-config-not-nested", replicas = 0, refreshInterval = "-1")
static class SampleEntityUUIDKeyed {
+ @Nullable @Id private UUID id;
+ @Nullable private String type;
+ @Nullable @Field(type = FieldType.Text, fielddata = true) private String message;
+ @Nullable private int rate;
+ @Nullable @ScriptedField private Long scriptedRate;
+ @Nullable private boolean available;
+ @Nullable private String highlightedMessage;
+ @Nullable private GeoPoint location;
+ @Nullable @Version private Long version;
- @Id private UUID id;
- private String type;
- @Field(type = FieldType.Text, fielddata = true) private String message;
- private int rate;
- @ScriptedField private Long scriptedRate;
- private boolean available;
- private String highlightedMessage;
- private GeoPoint location;
- @Version private Long version;
+ @Nullable
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(@Nullable UUID id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getType() {
+ return type;
+ }
+
+ public void setType(@Nullable String type) {
+ this.type = type;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ public int getRate() {
+ return rate;
+ }
+
+ public void setRate(int rate) {
+ this.rate = rate;
+ }
+
+ @Nullable
+ public java.lang.Long getScriptedRate() {
+ return scriptedRate;
+ }
+
+ public void setScriptedRate(@Nullable java.lang.Long scriptedRate) {
+ this.scriptedRate = scriptedRate;
+ }
+
+ public boolean isAvailable() {
+ return available;
+ }
+
+ public void setAvailable(boolean available) {
+ this.available = available;
+ }
+
+ @Nullable
+ public String getHighlightedMessage() {
+ return highlightedMessage;
+ }
+
+ public void setHighlightedMessage(@Nullable String highlightedMessage) {
+ this.highlightedMessage = highlightedMessage;
+ }
+
+ @Nullable
+ public GeoPoint getLocation() {
+ return location;
+ }
+
+ public void setLocation(@Nullable GeoPoint location) {
+ this.location = location;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplateCallbackTests.java b/src/test/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplateCallbackTests.java
index a4ea0314b..0131fb45d 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplateCallbackTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplateCallbackTests.java
@@ -19,10 +19,6 @@ import static java.util.Collections.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -443,13 +439,53 @@ abstract class AbstractElasticsearchTemplateCallbackTests {
assertThat(iterator.next().firstname).isEqualTo("before-convert");
}
- @Data
- @AllArgsConstructor
- @NoArgsConstructor
static class Person {
+ @Nullable @Id String id;
+ @Nullable String firstname;
- @Id String id;
- String firstname;
+ public Person(@Nullable String id, @Nullable String firstname) {
+ this.id = id;
+ this.firstname = firstname;
+ }
+
+ public Person() {
+ }
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(@Nullable String firstname) {
+ this.firstname = firstname;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Person person = (Person) o;
+
+ if (id != null ? !id.equals(person.id) : person.id != null) return false;
+ return firstname != null ? firstname.equals(person.firstname) : person.firstname == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (firstname != null ? firstname.hashCode() : 0);
+ return result;
+ }
}
static class ValueCapturingEntityCallback {
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplateTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplateTests.java
index 513629edc..8e8ae9701 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplateTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplateTests.java
@@ -21,10 +21,6 @@ import static org.skyscreamer.jsonassert.JSONAssert.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
-import lombok.Builder;
-import lombok.Data;
-import lombok.val;
-
import java.lang.Object;
import java.time.Duration;
import java.util.Collections;
@@ -37,6 +33,7 @@ import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.reindex.UpdateByQueryRequest;
+import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.json.JSONException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@@ -49,6 +46,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
+import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
/**
@@ -81,13 +79,29 @@ public class ElasticsearchRestTemplateTests extends ElasticsearchTemplateTests {
.isInstanceOf(UncategorizedElasticsearchException.class);
}
- @Data
- @Builder
@Document(indexName = "test-index-sample-core-rest-template", replicas = 0, refreshInterval = "-1")
static class SampleEntity {
-
- @Id private String id;
+ @Nullable @Id private String id;
+ @Nullable
@Field(type = Text, store = true, fielddata = true) private String type;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getType() {
+ return type;
+ }
+
+ public void setType(@Nullable String type) {
+ this.type = type;
+ }
}
@Test // DATAES-768
@@ -122,7 +136,7 @@ public class ElasticsearchRestTemplateTests extends ElasticsearchTemplateTests {
assertThat(request.retryOnConflict()).isEqualTo(7);
assertThat(request.timeout()).isEqualByComparingTo(TimeValue.parseTimeValue("4711s", "test"));
assertThat(request.waitForActiveShards()).isEqualTo(ActiveShardCount.ALL);
- val fetchSourceContext = request.fetchSource();
+ FetchSourceContext fetchSourceContext = request.fetchSource();
assertThat(fetchSourceContext).isNotNull();
assertThat(fetchSourceContext.includes()).containsExactlyInAnyOrder("incl");
assertThat(fetchSourceContext.excludes()).containsExactlyInAnyOrder("excl");
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java
index 68fd8085b..b05df9b71 100755
--- a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java
@@ -23,12 +23,6 @@ import static org.springframework.data.elasticsearch.core.document.Document.*;
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
import java.lang.Double;
import java.lang.Integer;
import java.lang.Long;
@@ -65,8 +59,6 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
-import org.elasticsearch.search.rescore.QueryRescoreMode;
-import org.elasticsearch.search.rescore.QueryRescorerBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
@@ -1989,8 +1981,11 @@ public abstract class ElasticsearchTemplateTests {
// given
String documentId = nextIdAsString();
- GTEVersionEntity entity = GTEVersionEntity.builder().id(documentId).name("FooBar")
- .version(System.currentTimeMillis()).build();
+
+ GTEVersionEntity entity = new GTEVersionEntity();
+ entity.setId(documentId);
+ entity.setName("FooBar");
+ entity.setVersion(System.currentTimeMillis());
IndexQueryBuilder indexQueryBuilder = new IndexQueryBuilder().withId(documentId).withVersion(entity.getVersion())
.withObject(entity);
@@ -3072,7 +3067,10 @@ public abstract class ElasticsearchTemplateTests {
@Test // DATAES-714
void shouldReturnSortFieldsInSearchHits() {
IndexCoordinates index = IndexCoordinates.of("test-index-searchhits-entity-template");
- SearchHitsEntity entity = SearchHitsEntity.builder().id("1").number(1000L).keyword("thousands").build();
+ SearchHitsEntity entity = new SearchHitsEntity();
+ entity.setId("1");
+ entity.setNumber(1000L);
+ entity.setKeyword("thousands");
IndexQuery indexQuery = new IndexQueryBuilder().withId(entity.getId()).withObject(entity).build();
operations.index(indexQuery, index);
operations.indexOps(index).refresh();
@@ -3107,10 +3105,9 @@ public abstract class ElasticsearchTemplateTests {
@Test // DATAES-715
void shouldReturnHighlightFieldsInSearchHit() {
IndexCoordinates index = IndexCoordinates.of("test-index-highlight-entity-template");
- HighlightEntity entity = HighlightEntity.builder().id("1")
- .message("This message is a long text which contains the word to search for "
- + "in two places, the first being near the beginning and the second near the end of the message")
- .build();
+ HighlightEntity entity = new HighlightEntity("1",
+ "This message is a long text which contains the word to search for "
+ + "in two places, the first being near the beginning and the second near the end of the message");
IndexQuery indexQuery = new IndexQueryBuilder().withId(entity.getId()).withObject(entity).build();
operations.index(indexQuery, index);
operations.indexOps(index).refresh();
@@ -3140,16 +3137,14 @@ public abstract class ElasticsearchTemplateTests {
SampleEntity entity = SampleEntity.builder() //
.id("1") //
.message("some message") //
- .rate(java.lang.Integer.MAX_VALUE)
- .version(System.currentTimeMillis()) //
+ .rate(java.lang.Integer.MAX_VALUE).version(System.currentTimeMillis()) //
.build();
// high score from rescore query
SampleEntity entity2 = SampleEntity.builder() //
.id("2") //
.message("nothing") //
- .rate(1)
- .version(System.currentTimeMillis()) //
+ .rate(1).version(System.currentTimeMillis()) //
.build();
List indexQueries = getIndexQueries(Arrays.asList(entity, entity2));
@@ -3158,26 +3153,15 @@ public abstract class ElasticsearchTemplateTests {
indexOperations.refresh();
NativeSearchQuery query = new NativeSearchQueryBuilder() //
- .withQuery(
- boolQuery().filter(existsQuery("rate")).should(termQuery("message", "message"))) //
- .withRescorerQuery(new RescorerQuery(
- new NativeSearchQueryBuilder().withQuery(
- QueryBuilders.functionScoreQuery(
- new FunctionScoreQueryBuilder.FilterFunctionBuilder[]{
- new FilterFunctionBuilder(
- new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5)
- .setWeight(1f)),
- new FilterFunctionBuilder(
- new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5)
- .setWeight(100f))}
- )
- .scoreMode(FunctionScoreQuery.ScoreMode.SUM)
- .maxBoost(80f)
- .boostMode(CombineFunction.REPLACE)
- ).build()
- )
- .withScoreMode(ScoreMode.Max)
- .withWindowSize(100))
+ .withQuery(boolQuery().filter(existsQuery("rate")).should(termQuery("message", "message"))) //
+ .withRescorerQuery(
+ new RescorerQuery(new NativeSearchQueryBuilder().withQuery(QueryBuilders
+ .functionScoreQuery(new FunctionScoreQueryBuilder.FilterFunctionBuilder[] {
+ new FilterFunctionBuilder(new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5).setWeight(1f)),
+ new FilterFunctionBuilder(
+ new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5).setWeight(100f)) })
+ .scoreMode(FunctionScoreQuery.ScoreMode.SUM).maxBoost(80f).boostMode(CombineFunction.REPLACE)).build())
+ .withScoreMode(ScoreMode.Max).withWindowSize(100))
.build();
SearchHits searchHits = operations.search(query, SampleEntity.class, index);
@@ -3187,12 +3171,12 @@ public abstract class ElasticsearchTemplateTests {
SearchHit searchHit = searchHits.getSearchHit(0);
assertThat(searchHit.getContent().getMessage()).isEqualTo("nothing");
- //score capped to 80
+ // score capped to 80
assertThat(searchHit.getScore()).isEqualTo(80f);
}
@Test
- // DATAES-738
+ // DATAES-738
void shouldSaveEntityWithIndexCoordinates() {
String id = "42";
SampleEntity entity = new SampleEntity();
@@ -3766,130 +3750,560 @@ public abstract class ElasticsearchTemplateTests {
assertThat(explanation).isNotNull();
}
- @Data
- @NoArgsConstructor
- @AllArgsConstructor
- @EqualsAndHashCode(exclude = "score")
- @Builder
@Document(indexName = INDEX_NAME_SAMPLE_ENTITY, replicas = 0, refreshInterval = "-1")
static class SampleEntity {
+ @Nullable @Id private String id;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String type;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String message;
+ @Nullable private int rate;
+ @Nullable @ScriptedField private Double scriptedRate;
+ @Nullable private boolean available;
+ @Nullable private GeoPoint location;
+ @Nullable @Version private Long version;
- @Id private String id;
- @Field(type = Text, store = true, fielddata = true) private String type;
- @Field(type = Text, store = true, fielddata = true) private String message;
- private int rate;
- @ScriptedField private Double scriptedRate;
- private boolean available;
- private GeoPoint location;
- @Version private Long version;
+ static Builder builder() {
+ return new Builder();
+ }
+
+ static class Builder {
+
+ @Nullable private String id;
+ @Nullable private String type;
+ @Nullable private String message;
+ @Nullable private Long version;
+ @Nullable private int rate;
+ @Nullable private GeoPoint location;
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder type(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public Builder message(String message) {
+ this.message = message;
+ return this;
+ }
+
+ public Builder version(Long version) {
+ this.version = version;
+ return this;
+ }
+
+ public Builder rate(int rate) {
+ this.rate = rate;
+ return this;
+ }
+
+ public Builder location(GeoPoint location) {
+ this.location = location;
+ return this;
+ }
+
+ public SampleEntity build() {
+ SampleEntity sampleEntity = new SampleEntity();
+ sampleEntity.setId(id);
+ sampleEntity.setType(type);
+ sampleEntity.setMessage(message);
+ sampleEntity.setRate(rate);
+ sampleEntity.setVersion(version);
+ sampleEntity.setLocation(location);
+ return sampleEntity;
+ }
+ }
+
+ public SampleEntity() {}
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getType() {
+ return type;
+ }
+
+ public void setType(@Nullable String type) {
+ this.type = type;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ public int getRate() {
+ return rate;
+ }
+
+ public void setRate(int rate) {
+ this.rate = rate;
+ }
+
+ @Nullable
+ public java.lang.Double getScriptedRate() {
+ return scriptedRate;
+ }
+
+ public void setScriptedRate(@Nullable java.lang.Double scriptedRate) {
+ this.scriptedRate = scriptedRate;
+ }
+
+ public boolean isAvailable() {
+ return available;
+ }
+
+ public void setAvailable(boolean available) {
+ this.available = available;
+ }
+
+ @Nullable
+ public GeoPoint getLocation() {
+ return location;
+ }
+
+ public void setLocation(@Nullable GeoPoint location) {
+ this.location = location;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ SampleEntity that = (SampleEntity) o;
+
+ if (rate != that.rate)
+ return false;
+ if (available != that.available)
+ return false;
+ if (id != null ? !id.equals(that.id) : that.id != null)
+ return false;
+ if (type != null ? !type.equals(that.type) : that.type != null)
+ return false;
+ if (message != null ? !message.equals(that.message) : that.message != null)
+ return false;
+ if (scriptedRate != null ? !scriptedRate.equals(that.scriptedRate) : that.scriptedRate != null)
+ return false;
+ if (location != null ? !location.equals(that.location) : that.location != null)
+ return false;
+ return version != null ? version.equals(that.version) : that.version == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ result = 31 * result + (message != null ? message.hashCode() : 0);
+ result = 31 * result + rate;
+ result = 31 * result + (scriptedRate != null ? scriptedRate.hashCode() : 0);
+ result = 31 * result + (available ? 1 : 0);
+ result = 31 * result + (location != null ? location.hashCode() : 0);
+ result = 31 * result + (version != null ? version.hashCode() : 0);
+ return result;
+ }
}
- /**
- * @author Gad Akuka
- * @author Rizwan Idrees
- * @author Mohsin Husen
- */
- @Data
- @AllArgsConstructor
- @Builder
@Document(indexName = "test-index-uuid-keyed-core-template", replicas = 0, refreshInterval = "-1")
private static class SampleEntityUUIDKeyed {
+ @Nullable @Id private UUID id;
+ @Nullable private String type;
+ @Nullable @Field(type = FieldType.Text, fielddata = true) private String message;
+ @Nullable private int rate;
+ @Nullable @ScriptedField private Long scriptedRate;
+ @Nullable private boolean available;
+ @Nullable private GeoPoint location;
+ @Nullable @Version private Long version;
- @Id private UUID id;
- private String type;
- @Field(type = FieldType.Text, fielddata = true) private String message;
- private int rate;
- @ScriptedField private Long scriptedRate;
- private boolean available;
- private GeoPoint location;
- @Version private Long version;
+ @Nullable
+ public UUID getId() {
+ return id;
+ }
+ public void setId(@Nullable UUID id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getType() {
+ return type;
+ }
+
+ public void setType(@Nullable String type) {
+ this.type = type;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ public int getRate() {
+ return rate;
+ }
+
+ public void setRate(int rate) {
+ this.rate = rate;
+ }
+
+ @Nullable
+ public java.lang.Long getScriptedRate() {
+ return scriptedRate;
+ }
+
+ public void setScriptedRate(@Nullable java.lang.Long scriptedRate) {
+ this.scriptedRate = scriptedRate;
+ }
+
+ public boolean isAvailable() {
+ return available;
+ }
+
+ public void setAvailable(boolean available) {
+ this.available = available;
+ }
+
+ @Nullable
+ public GeoPoint getLocation() {
+ return location;
+ }
+
+ public void setLocation(@Nullable GeoPoint location) {
+ this.location = location;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
}
- @Data
- @Builder
- @AllArgsConstructor
- @NoArgsConstructor
@Document(indexName = "test-index-book-core-template", replicas = 0, refreshInterval = "-1")
static class Book {
-
- @Id private String id;
- private String name;
- @Field(type = FieldType.Object) private Author author;
- @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>();
- @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
+ @Nullable @Id private String id;
+ @Nullable private String name;
+ @Nullable @Field(type = FieldType.Object) private Author author;
+ @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>();
+ @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"),
otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop",
searchAnalyzer = "standard") }) private String description;
+
+ public Book(@Nullable String id, @Nullable String name, @Nullable Author author,
+ @Nullable Map> buckets, @Nullable String description) {
+ this.id = id;
+ this.name = name;
+ this.author = author;
+ this.buckets = buckets;
+ this.description = description;
+ }
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
+
+ @Nullable
+ public Author getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(@Nullable Author author) {
+ this.author = author;
+ }
+
+ @Nullable
+ public Map> getBuckets() {
+ return buckets;
+ }
+
+ public void setBuckets(@Nullable Map> buckets) {
+ this.buckets = buckets;
+ }
+
+ @Nullable
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(@Nullable String description) {
+ this.description = description;
+ }
+
+ static Builder builder() {
+ return new Builder();
+ }
+
+ static class Builder {
+ @Nullable private String id;
+ @Nullable private String name;
+ @Nullable private Author author;
+ @Nullable private Map> buckets = new HashMap<>();
+ @Nullable private String description;
+
+ public Builder id(@Nullable String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder name(@Nullable String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder author(@Nullable Author author) {
+ this.author = author;
+ return this;
+ }
+
+ public Builder buckets(@Nullable Map> buckets) {
+ this.buckets = buckets;
+ return this;
+ }
+
+ public Builder description(@Nullable String description) {
+ this.description = description;
+ return this;
+ }
+
+ Book build() {
+ return new Book(id, name, author, buckets, description);
+ }
+ }
}
- @Data
static class Author {
- private String id;
- private String name;
+ @Nullable private String id;
+ @Nullable private String name;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
}
- @Data
- @Builder
- @AllArgsConstructor
- @NoArgsConstructor
@Document(indexName = "test-index-version-core-template", replicas = 0, refreshInterval = "-1",
versionType = VersionType.EXTERNAL_GTE)
private static class GTEVersionEntity {
+ @Nullable @Version private Long version;
+ @Nullable @Id private String id;
+ @Nullable private String name;
- @Version private Long version;
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
- @Id private String id;
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
- private String name;
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
}
- @Data
@Document(indexName = "test-index-hetro1-core-template", replicas = 0)
static class HetroEntity1 {
-
- @Id private String id;
- private String firstName;
- @Version private Long version;
+ @Nullable @Id private String id;
+ @Nullable private String firstName;
+ @Nullable @Version private Long version;
HetroEntity1(String id, String firstName) {
this.id = id;
this.firstName = firstName;
this.version = System.currentTimeMillis();
}
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(@Nullable String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
}
- @Data
@Document(indexName = "test-index-hetro2-core-template", replicas = 0)
static class HetroEntity2 {
- @Id private String id;
- private String lastName;
- @Version private Long version;
+ @Nullable @Id private String id;
+ @Nullable private String lastName;
+ @Nullable @Version private Long version;
HetroEntity2(String id, String lastName) {
this.id = id;
this.lastName = lastName;
this.version = System.currentTimeMillis();
}
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(@Nullable String lastName) {
+ this.lastName = lastName;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
}
- @Data
@Document(indexName = "test-index-server-configuration", useServerConfiguration = true, shards = 10, replicas = 10,
refreshInterval = "-1")
private static class UseServerConfigurationEntity {
- @Id private String id;
- private String val;
+ @Nullable @Id private String id;
+ @Nullable private String val;
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getVal() {
+ return val;
+ }
+
+ public void setVal(@Nullable String val) {
+ this.val = val;
+ }
}
- @Data
@Document(indexName = "test-index-sample-mapping", replicas = 0, refreshInterval = "-1")
static class SampleMappingEntity {
- @Id private String id;
+ @Nullable @Id private String id;
+ @Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
- @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
static class NestedEntity {
@@ -3906,58 +4320,211 @@ public abstract class ElasticsearchTemplateTests {
}
}
- @Data
- @AllArgsConstructor
- @Builder
@Document(indexName = "test-index-searchhits-entity-template")
static class SearchHitsEntity {
- @Id private String id;
- @Field(type = FieldType.Long) Long number;
- @Field(type = FieldType.Keyword) String keyword;
+ @Nullable @Id private String id;
+ @Nullable @Field(type = FieldType.Long) Long number;
+ @Nullable @Field(type = FieldType.Keyword) String keyword;
+
+ public SearchHitsEntity() {}
+
+ public SearchHitsEntity(@Nullable String id, @Nullable java.lang.Long number, @Nullable String keyword) {
+ this.id = id;
+ this.number = number;
+ this.keyword = keyword;
+ }
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public java.lang.Long getNumber() {
+ return number;
+ }
+
+ public void setNumber(@Nullable java.lang.Long number) {
+ this.number = number;
+ }
+
+ @Nullable
+ public String getKeyword() {
+ return keyword;
+ }
+
+ public void setKeyword(@Nullable String keyword) {
+ this.keyword = keyword;
+ }
}
- @Data
- @AllArgsConstructor
- @Builder
@Document(indexName = "test-index-highlight-entity-template")
static class HighlightEntity {
- @Id private String id;
- private String message;
+ @Nullable @Id private String id;
+ @Nullable private String message;
+
+ public HighlightEntity(@Nullable String id, @Nullable String message) {
+ this.id = id;
+ this.message = message;
+ }
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
}
- @Data
@Document(indexName = "test-index-optimistic-entity-template")
static class OptimisticEntity {
- @Id private String id;
- private String message;
- private SeqNoPrimaryTerm seqNoPrimaryTerm;
+ @Nullable @Id private String id;
+ @Nullable private String message;
+ @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ @Nullable
+ public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
+ return seqNoPrimaryTerm;
+ }
+
+ public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
+ this.seqNoPrimaryTerm = seqNoPrimaryTerm;
+ }
}
- @Data
@Document(indexName = "test-index-optimistic-and-versioned-entity-template")
static class OptimisticAndVersionedEntity {
- @Id private String id;
- private String message;
- private SeqNoPrimaryTerm seqNoPrimaryTerm;
- @Version private Long version;
+ @Nullable @Id private String id;
+ @Nullable private String message;
+ @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
+ @Nullable @Version private Long version;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ @Nullable
+ public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
+ return seqNoPrimaryTerm;
+ }
+
+ public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
+ this.seqNoPrimaryTerm = seqNoPrimaryTerm;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
}
- @Data
@Document(indexName = "test-index-versioned-entity-template")
static class VersionedEntity {
- @Id private String id;
- @Version private Long version;
+ @Nullable @Id private String id;
+ @Nullable @Version private Long version;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
}
- @Data
- @NoArgsConstructor
- @AllArgsConstructor
- @Builder
@Document(indexName = INDEX_NAME_JOIN_SAMPLE_ENTITY)
static class SampleJoinEntity {
- @Id @Field(type = Keyword) private String uuid;
- @JoinTypeRelations(relations = {
+ @Nullable @Id @Field(type = Keyword) private String uuid;
+ @Nullable @JoinTypeRelations(relations = {
@JoinTypeRelation(parent = "question", children = { "answer" }) }) private JoinField myJoinField;
- @Field(type = Text) private String text;
+ @Nullable @Field(type = Text) private String text;
+
+ @Nullable
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(@Nullable String uuid) {
+ this.uuid = uuid;
+ }
+
+ @Nullable
+ public JoinField getMyJoinField() {
+ return myJoinField;
+ }
+
+ public void setMyJoinField(@Nullable JoinField myJoinField) {
+ this.myJoinField = myJoinField;
+ }
+
+ @Nullable
+ public String getText() {
+ return text;
+ }
+
+ public void setText(@Nullable String text) {
+ this.text = text;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTransportTemplateTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTransportTemplateTests.java
index 864d58fe1..485e00575 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTransportTemplateTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTransportTemplateTests.java
@@ -21,9 +21,6 @@ import static org.skyscreamer.jsonassert.JSONAssert.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
-import lombok.Data;
-import lombok.val;
-
import java.lang.Object;
import java.time.Duration;
import java.util.Collections;
@@ -55,6 +52,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
+import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
/**
@@ -108,18 +106,18 @@ public class ElasticsearchTransportTemplateTests extends ElasticsearchTemplateTe
doc.put("message", "test");
org.springframework.data.elasticsearch.core.document.Document document = org.springframework.data.elasticsearch.core.document.Document
.from(doc);
- UpdateQuery updateQuery = UpdateQuery.builder("1") //
- .withDocument(document) //
- .withIfSeqNo(42) //
- .withIfPrimaryTerm(13) //
- .withScript("script")//
- .withLang("lang") //
- .withRefreshPolicy(RefreshPolicy.WAIT_UNTIL) //
- .withRetryOnConflict(7) //
- .withTimeout("4711s") //
- .withWaitForActiveShards("all").withFetchSourceIncludes(Collections.singletonList("incl")) //
- .withFetchSourceExcludes(Collections.singletonList("excl")) //
- .build();
+ UpdateQuery updateQuery = UpdateQuery.builder("1") //
+ .withDocument(document) //
+ .withIfSeqNo(42) //
+ .withIfPrimaryTerm(13) //
+ .withScript("script")//
+ .withLang("lang") //
+ .withRefreshPolicy(RefreshPolicy.WAIT_UNTIL) //
+ .withRetryOnConflict(7) //
+ .withTimeout("4711s") //
+ .withWaitForActiveShards("all").withFetchSourceIncludes(Collections.singletonList("incl")) //
+ .withFetchSourceExcludes(Collections.singletonList("excl")) //
+ .build();
UpdateRequestBuilder request = getRequestFactory().updateRequestBuilderFor(client, updateQuery,
IndexCoordinates.of("index"));
@@ -133,7 +131,7 @@ public class ElasticsearchTransportTemplateTests extends ElasticsearchTemplateTe
assertThat(request.request().retryOnConflict()).isEqualTo(7);
assertThat(request.request().timeout()).isEqualByComparingTo(TimeValue.parseTimeValue("4711s", "test"));
assertThat(request.request().waitForActiveShards()).isEqualTo(ActiveShardCount.ALL);
- FetchSourceContext fetchSourceContext = request.request().fetchSource();
+ FetchSourceContext fetchSourceContext = request.request().fetchSource();
assertThat(fetchSourceContext).isNotNull();
assertThat(fetchSourceContext.includes()).containsExactlyInAnyOrder("incl");
assertThat(fetchSourceContext.excludes()).containsExactlyInAnyOrder("excl");
@@ -197,11 +195,25 @@ public class ElasticsearchTransportTemplateTests extends ElasticsearchTemplateTe
assertThat(request.request().getScript().getType()).isEqualTo(org.elasticsearch.script.ScriptType.STORED);
}
- @Data
@Document(indexName = "test-index-sample-core-transport-template", replicas = 0, refreshInterval = "-1")
static class SampleEntity {
+ @Nullable @Id private String id;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String type;
- @Id private String id;
- @Field(type = Text, store = true, fielddata = true) private String type;
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/EntityOperationsTest.java b/src/test/java/org/springframework/data/elasticsearch/core/EntityOperationsTest.java
index 0f0fa40d5..cf266ab92 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/EntityOperationsTest.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/EntityOperationsTest.java
@@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.core;
import static org.assertj.core.api.Assertions.*;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
import java.util.Arrays;
import java.util.HashSet;
@@ -66,7 +61,9 @@ class EntityOperationsTest {
@DisplayName("should return routing from DefaultRoutingAccessor")
void shouldReturnRoutingFromDefaultRoutingAccessor() {
- EntityWithRouting entity = EntityWithRouting.builder().id("42").routing("theRoute").build();
+ EntityWithRouting entity = new EntityWithRouting();
+ entity.setId("42");
+ entity.setRouting("theRoute");
EntityOperations.AdaptibleEntity adaptibleEntity = entityOperations.forEntity(entity,
conversionService, new DefaultRoutingResolver(mappingContext));
@@ -79,8 +76,9 @@ class EntityOperationsTest {
@DisplayName("should return routing from JoinField when routing value is null")
void shouldReturnRoutingFromJoinFieldWhenRoutingValueIsNull() {
- EntityWithRoutingAndJoinField entity = EntityWithRoutingAndJoinField.builder().id("42")
- .joinField(new JoinField<>("foo", "foo-routing")).build();
+ EntityWithRoutingAndJoinField entity = new EntityWithRoutingAndJoinField();
+ entity.setId("42");
+ entity.setJoinField(new JoinField<>("foo", "foo-routing"));
EntityOperations.AdaptibleEntity adaptibleEntity = entityOperations.forEntity(entity,
conversionService, new DefaultRoutingResolver(mappingContext));
@@ -93,8 +91,10 @@ class EntityOperationsTest {
@Test // #1218
@DisplayName("should return routing from routing when JoinField is set")
void shouldReturnRoutingFromRoutingWhenJoinFieldIsSet() {
- EntityWithRoutingAndJoinField entity = EntityWithRoutingAndJoinField.builder().id("42").routing("theRoute")
- .joinField(new JoinField<>("foo", "foo-routing")).build();
+ EntityWithRoutingAndJoinField entity = new EntityWithRoutingAndJoinField();
+ entity.setId("42");
+ entity.setRouting("theRoute");
+ entity.setJoinField(new JoinField<>("foo", "foo-routing"));
EntityOperations.AdaptibleEntity adaptibleEntity = entityOperations.forEntity(entity,
conversionService, new DefaultRoutingResolver(mappingContext));
@@ -104,26 +104,63 @@ class EntityOperationsTest {
assertThat(routing).isEqualTo("theRoute");
}
- @Data
- @Builder
- @NoArgsConstructor
- @AllArgsConstructor
@Document(indexName = "entity-operations-test")
@Routing("routing")
static class EntityWithRouting {
- @Id private String id;
- private String routing;
+ @Nullable @Id private String id;
+ @Nullable private String routing;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getRouting() {
+ return routing;
+ }
+
+ public void setRouting(@Nullable String routing) {
+ this.routing = routing;
+ }
}
- @Data
- @Builder
- @NoArgsConstructor
- @AllArgsConstructor
@Document(indexName = "entity-operations-test")
@Routing("routing")
static class EntityWithRoutingAndJoinField {
- @Id private String id;
- private String routing;
- private JoinField joinField;
+ @Nullable @Id private String id;
+ @Nullable private String routing;
+ @Nullable private JoinField joinField;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getRouting() {
+ return routing;
+ }
+
+ public void setRouting(@Nullable String routing) {
+ this.routing = routing;
+ }
+
+ @Nullable
+ public JoinField getJoinField() {
+ return joinField;
+ }
+
+ public void setJoinField(@Nullable JoinField joinField) {
+ this.joinField = joinField;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/InnerHitsTests.java b/src/test/java/org/springframework/data/elasticsearch/core/InnerHitsTests.java
index e4406b1e5..9bd1a1706 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/InnerHitsTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/InnerHitsTests.java
@@ -18,10 +18,6 @@ package org.springframework.data.elasticsearch.core;
import static org.assertj.core.api.Assertions.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.RequiredArgsConstructor;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -132,39 +128,103 @@ public class InnerHitsTests {
softly.assertAll();
}
- @Data
- @AllArgsConstructor
- @RequiredArgsConstructor
@Document(indexName = INDEX_NAME)
static class City {
-
- @Id private String name;
-
+ @Nullable @Id private String name;
// NOTE: using a custom names here to cover property name matching
- @Field(name = "hou-ses", type = FieldType.Nested) private Collection houses = new ArrayList<>();
+ @Nullable @Field(name = "hou-ses", type = FieldType.Nested) private Collection houses = new ArrayList<>();
+
+ public City(@Nullable String name, @Nullable Collection houses) {
+ this.name = name;
+ this.houses = houses;
+ }
+
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
+
+ @Nullable
+ public Collection getHouses() {
+ return houses;
+ }
+
+ public void setHouses(@Nullable Collection houses) {
+ this.houses = houses;
+ }
}
- @Data
- @AllArgsConstructor
- @RequiredArgsConstructor
static class House {
-
- @Field(type = FieldType.Text) private String street;
-
- @Field(type = FieldType.Text) private String streetNumber;
-
+ @Nullable @Field(type = FieldType.Text) private String street;
+ @Nullable @Field(type = FieldType.Text) private String streetNumber;
// NOTE: using a custom names here to cover property name matching
- @Field(name = "in-habi-tants", type = FieldType.Nested) private List inhabitants = new ArrayList<>();
+ @Nullable @Field(name = "in-habi-tants",
+ type = FieldType.Nested) private List inhabitants = new ArrayList<>();
+
+ public House(@Nullable String street, @Nullable String streetNumber, @Nullable List inhabitants) {
+ this.street = street;
+ this.streetNumber = streetNumber;
+ this.inhabitants = inhabitants;
+ }
+
+ @Nullable
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(@Nullable String street) {
+ this.street = street;
+ }
+
+ @Nullable
+ public String getStreetNumber() {
+ return streetNumber;
+ }
+
+ public void setStreetNumber(@Nullable String streetNumber) {
+ this.streetNumber = streetNumber;
+ }
+
+ @Nullable
+ public List getInhabitants() {
+ return inhabitants;
+ }
+
+ public void setInhabitants(@Nullable List inhabitants) {
+ this.inhabitants = inhabitants;
+ }
}
- @Data
- @AllArgsConstructor
- @RequiredArgsConstructor
static class Inhabitant {
// NOTE: using a custom names here to cover property name matching
+ @Nullable @Field(name = "first-name", type = FieldType.Text) private String firstName;
+ @Nullable @Field(name = "last-name", type = FieldType.Text) private String lastName;
- @Field(name = "first-name", type = FieldType.Text) private String firstName;
+ public Inhabitant(@Nullable String firstName, @Nullable String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
- @Field(name = "last-name", type = FieldType.Text) private String lastName;
+ @Nullable
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(@Nullable String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Nullable
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(@Nullable String lastName) {
+ this.lastName = lastName;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/LogEntityTests.java b/src/test/java/org/springframework/data/elasticsearch/core/LogEntityTests.java
index fb2d5be77..a54ca91ea 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/LogEntityTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/LogEntityTests.java
@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
-import lombok.Data;
-
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@@ -44,6 +42,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.data.elasticsearch.utils.IndexInitializer;
+import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
/**
@@ -133,21 +132,16 @@ public class LogEntityTests {
/**
* Simple type to test facets
*/
- @Data
@Document(indexName = "test-index-log-core", replicas = 0, refreshInterval = "-1")
static class LogEntity {
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- @Id private String id;
-
- private String action;
-
- private long sequenceCode;
-
- @Field(type = Ip) private String ip;
-
- @Field(type = Date, format = DateFormat.date_time) private java.util.Date date;
+ @Nullable @Id private String id;
+ @Nullable private String action;
+ @Nullable private long sequenceCode;
+ @Nullable @Field(type = Ip) private String ip;
+ @Nullable @Field(type = Date, format = DateFormat.date_time) private java.util.Date date;
private LogEntity() {}
@@ -155,6 +149,49 @@ public class LogEntityTests {
this.id = id;
}
+ public static SimpleDateFormat getFormat() {
+ return format;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public long getSequenceCode() {
+ return sequenceCode;
+ }
+
+ public void setSequenceCode(long sequenceCode) {
+ this.sequenceCode = sequenceCode;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public java.util.Date getDate() {
+ return date;
+ }
+
+ public void setDate(java.util.Date date) {
+ this.date = date;
+ }
}
/**
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateCallbackTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateCallbackTests.java
index bfff6f2f6..aaeb3bdd8 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateCallbackTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateCallbackTests.java
@@ -18,9 +18,6 @@ package org.springframework.data.elasticsearch.core;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.get.MultiGetItemResponse;
import reactor.core.publisher.Flux;
@@ -378,13 +375,53 @@ public class ReactiveElasticsearchTemplateCallbackTests {
assertThat(saved.get(1).firstname).isEqualTo("before-convert");
}
- @Data
- @AllArgsConstructor
- @NoArgsConstructor
static class Person {
+ @Nullable @Id String id;
+ @Nullable String firstname;
- @Id String id;
- String firstname;
+ public Person() {
+ }
+
+ public Person(@Nullable String id, @Nullable String firstname) {
+ this.id = id;
+ this.firstname = firstname;
+ }
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(@Nullable String firstname) {
+ this.firstname = firstname;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Person person = (Person) o;
+
+ if (id != null ? !id.equals(person.id) : person.id != null) return false;
+ return firstname != null ? firstname.equals(person.firstname) : person.firstname == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (firstname != null ? firstname.hashCode() : 0);
+ return result;
+ }
}
static class ValueCapturingEntityCallback {
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateIntegrationTests.java
index ec8c25153..45e580f46 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateIntegrationTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateIntegrationTests.java
@@ -20,11 +20,6 @@ import static org.assertj.core.api.Assertions.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -81,6 +76,7 @@ import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.*;
import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
+import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
/**
@@ -179,7 +175,8 @@ public class ReactiveElasticsearchTemplateIntegrationTests {
@Test // DATAES-504
public void insertWithAutogeneratedIdShouldUpdateEntityId() {
- SampleEntity sampleEntity = SampleEntity.builder().message("wohoo").build();
+ SampleEntity sampleEntity = new SampleEntity();
+ sampleEntity.setMessage("wohoo");
template.save(sampleEntity) //
.map(SampleEntity::getId) //
@@ -1157,10 +1154,11 @@ public class ReactiveElasticsearchTemplateIntegrationTests {
// region Helper functions
private SampleEntity randomEntity(String message) {
- return SampleEntity.builder() //
- .id(UUID.randomUUID().toString()) //
- .message(StringUtils.hasText(message) ? message : "test message") //
- .version(System.currentTimeMillis()).build();
+ SampleEntity entity = new SampleEntity();
+ entity.setId(UUID.randomUUID().toString());
+ entity.setMessage(StringUtils.hasText(message) ? message : "test message");
+ entity.setVersion(System.currentTimeMillis());
+ return entity;
}
private IndexQuery getIndexQuery(SampleEntity sampleEntity) {
@@ -1187,75 +1185,259 @@ public class ReactiveElasticsearchTemplateIntegrationTests {
// endregion
// region Entities
- @Data
@Document(indexName = "marvel")
static class Person {
-
- private @Id String id;
- private String name;
- private int age;
+ @Nullable private @Id String id;
+ @Nullable private String name;
+ @Nullable private int age;
public Person() {}
public Person(String name, int age) {
-
this.name = name;
this.age = age;
}
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
}
- @Data
- @AllArgsConstructor
- @NoArgsConstructor
static class Message {
+ @Nullable String message;
- String message;
+ public Message(String message) {
+ this.message = message;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Message message1 = (Message) o;
+
+ return message != null ? message.equals(message1.message) : message1.message == null;
+ }
+
+ @Override
+ public int hashCode() {
+ return message != null ? message.hashCode() : 0;
+ }
}
- @Data
- @Builder
- @NoArgsConstructor
- @AllArgsConstructor
- @EqualsAndHashCode(exclude = "score")
@Document(indexName = DEFAULT_INDEX, replicas = 0, refreshInterval = "-1")
static class SampleEntity {
+ @Nullable @Id private String id;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String message;
+ @Nullable private int rate;
+ @Nullable @Version private Long version;
- @Id private String id;
- @Field(type = Text, store = true, fielddata = true) private String message;
- private int rate;
- @Version private Long version;
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ public int getRate() {
+ return rate;
+ }
+
+ public void setRate(int rate) {
+ this.rate = rate;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ SampleEntity that = (SampleEntity) o;
+
+ if (rate != that.rate) return false;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+ if (message != null ? !message.equals(that.message) : that.message != null) return false;
+ return version != null ? version.equals(that.version) : that.version == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (message != null ? message.hashCode() : 0);
+ result = 31 * result + rate;
+ result = 31 * result + (version != null ? version.hashCode() : 0);
+ return result;
+ }
}
- @Data
@Document(indexName = "test-index-reactive-optimistic-entity-template")
static class OptimisticEntity {
- @Id private String id;
- private String message;
- private SeqNoPrimaryTerm seqNoPrimaryTerm;
+ @Nullable @Id private String id;
+ @Nullable private String message;
+ @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ @Nullable
+ public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
+ return seqNoPrimaryTerm;
+ }
+
+ public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
+ this.seqNoPrimaryTerm = seqNoPrimaryTerm;
+ }
}
- @Data
@Document(indexName = "test-index-reactive-optimistic-and-versioned-entity-template")
static class OptimisticAndVersionedEntity {
- @Id private String id;
- private String message;
- private SeqNoPrimaryTerm seqNoPrimaryTerm;
- @Version private Long version;
+ @Nullable @Id private String id;
+ @Nullable private String message;
+ @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm;
+ @Nullable @Version private Long version;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(@Nullable String message) {
+ this.message = message;
+ }
+
+ @Nullable
+ public SeqNoPrimaryTerm getSeqNoPrimaryTerm() {
+ return seqNoPrimaryTerm;
+ }
+
+ public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
+ this.seqNoPrimaryTerm = seqNoPrimaryTerm;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
}
- @Data
@Document(indexName = "test-index-reactive-versioned-entity-template")
static class VersionedEntity {
- @Id private String id;
- @Version private Long version;
+ @Nullable @Id private String id;
+ @Nullable @Version private Long version;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(@Nullable java.lang.Long version) {
+ this.version = version;
+ }
}
- @Data
@Document(indexName = "test-index-reactive-information-list", createIndex = false)
@Setting(settingPath = "settings/test-settings.json")
@Mapping(mappingPath = "mappings/test-mappings.json")
private static class EntityWithSettingsAndMappingsReactive {
- @Id String id;
+ @Nullable @Id String id;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
}
// endregion
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateUnitTests.java
index fb467a144..98eb8dc65 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateUnitTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateUnitTests.java
@@ -20,10 +20,6 @@ import static org.elasticsearch.action.search.SearchRequest.*;
import static org.mockito.Mockito.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -62,6 +58,7 @@ import org.springframework.data.elasticsearch.core.query.Criteria;
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.StringQuery;
+import org.springframework.lang.Nullable;
/**
* @author Christoph Strobl
@@ -253,27 +250,89 @@ public class ReactiveElasticsearchTemplateUnitTests {
assertThat(captor.getValue().indicesOptions()).isEqualTo(IndicesOptions.LENIENT_EXPAND_OPEN);
}
- /**
- * @author Rizwan Idrees
- * @author Mohsin Husen
- * @author Chris White
- * @author Sascha Woo
- */
- @Data
- @NoArgsConstructor
- @AllArgsConstructor
- @Builder
@Document(indexName = "test-index-sample-core-reactive-template-Unit", replicas = 0, refreshInterval = "-1")
static class SampleEntity {
- @Id private String id;
- @Field(type = Text, store = true, fielddata = true) private String type;
- @Field(type = Text, store = true, fielddata = true) private String message;
- private int rate;
- @ScriptedField private Double scriptedRate;
- private boolean available;
- private String highlightedMessage;
- private GeoPoint location;
- @Version private Long version;
+ @Nullable @Id private String id;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String type;
+ @Nullable @Field(type = Text, store = true, fielddata = true) private String message;
+ @Nullable private int rate;
+ @Nullable @ScriptedField private Double scriptedRate;
+ @Nullable private boolean available;
+ @Nullable private String highlightedMessage;
+ @Nullable private GeoPoint location;
+ @Nullable @Version private Long version;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public int getRate() {
+ return rate;
+ }
+
+ public void setRate(int rate) {
+ this.rate = rate;
+ }
+
+ public java.lang.Double getScriptedRate() {
+ return scriptedRate;
+ }
+
+ public void setScriptedRate(java.lang.Double scriptedRate) {
+ this.scriptedRate = scriptedRate;
+ }
+
+ public boolean isAvailable() {
+ return available;
+ }
+
+ public void setAvailable(boolean available) {
+ this.available = available;
+ }
+
+ public String getHighlightedMessage() {
+ return highlightedMessage;
+ }
+
+ public void setHighlightedMessage(String highlightedMessage) {
+ this.highlightedMessage = highlightedMessage;
+ }
+
+ public GeoPoint getLocation() {
+ return location;
+ }
+
+ public void setLocation(GeoPoint location) {
+ this.location = location;
+ }
+
+ public java.lang.Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(java.lang.Long version) {
+ this.version = version;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperationsTest.java b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperationsTest.java
index 01e6e9dd9..8348b98ef 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperationsTest.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperationsTest.java
@@ -18,7 +18,6 @@ package org.springframework.data.elasticsearch.core;
import static org.assertj.core.api.Assertions.*;
import static org.skyscreamer.jsonassert.JSONAssert.*;
-import lombok.Data;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -506,27 +505,69 @@ public class ReactiveIndexOperationsTest {
assertThat(exists).isFalse();
}
- @Data
@Document(indexName = TESTINDEX, shards = 3, replicas = 2, refreshInterval = "4s")
static class Entity {
- @Id private String id;
- @Field(type = FieldType.Text) private String text;
- @Field(name = "publication-date", type = FieldType.Date,
+ @Nullable @Id private String id;
+ @Nullable @Field(type = FieldType.Text) private String text;
+ @Nullable @Field(name = "publication-date", type = FieldType.Date,
format = DateFormat.basic_date) private LocalDate publicationDate;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getText() {
+ return text;
+ }
+
+ public void setText(@Nullable String text) {
+ this.text = text;
+ }
+
+ @Nullable
+ public LocalDate getPublicationDate() {
+ return publicationDate;
+ }
+
+ public void setPublicationDate(@Nullable LocalDate publicationDate) {
+ this.publicationDate = publicationDate;
+ }
}
- @Data
@Document(indexName = TESTINDEX, useServerConfiguration = true)
static class EntityUseServerConfig {
- @Id private String id;
+ @Nullable @Id private String id;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
}
- @Data
@Document(indexName = TESTINDEX)
@Setting(settingPath = "/settings/test-settings.json")
@Mapping(mappingPath = "/mappings/test-mappings.json")
static class EntityWithAnnotatedSettingsAndMappings {
- @Id private String id;
+ @Nullable @Id private String id;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
}
@Document(indexName = "test-template", shards = 3, replicas = 2, refreshInterval = "5s")
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java b/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java
index b06b7edbf..ffc7ef184 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java
@@ -20,11 +20,6 @@ import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.mockito.Mockito.*;
import static org.skyscreamer.jsonassert.JSONAssert.*;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
@@ -460,8 +455,7 @@ class RequestFactoryTests {
@DisplayName("should set op_type INDEX if not specified")
void shouldSetOpTypeIndexIfNotSpecifiedAndIdIsSet() {
- IndexQuery indexQuery = new IndexQueryBuilder().withId("42").withObject(Person.builder().id("42").lastName("Smith"))
- .build();
+ IndexQuery indexQuery = new IndexQueryBuilder().withId("42").withObject(new Person("42", "Smith")).build();
IndexRequest indexRequest = requestFactory.indexRequest(indexQuery, IndexCoordinates.of("optype"));
@@ -473,7 +467,7 @@ class RequestFactoryTests {
void shouldSetOpTypeCreateIfSpecified() {
IndexQuery indexQuery = new IndexQueryBuilder().withOpType(IndexQuery.OpType.CREATE).withId("42")
- .withObject(Person.builder().id("42").lastName("Smith")).build();
+ .withObject(new Person("42", "Smith")).build();
IndexRequest indexRequest = requestFactory.indexRequest(indexQuery, IndexCoordinates.of("optype"));
@@ -485,7 +479,7 @@ class RequestFactoryTests {
void shouldSetOpTypeIndexIfSpecified() {
IndexQuery indexQuery = new IndexQueryBuilder().withOpType(IndexQuery.OpType.INDEX).withId("42")
- .withObject(Person.builder().id("42").lastName("Smith")).build();
+ .withObject(new Person("42", "Smith")).build();
IndexRequest indexRequest = requestFactory.indexRequest(indexQuery, IndexCoordinates.of("optype"));
@@ -601,14 +595,50 @@ class RequestFactoryTests {
assertEquals(expected, searchRequest, false);
}
- @Data
- @Builder
- @NoArgsConstructor
- @AllArgsConstructor
static class Person {
@Nullable @Id String id;
@Nullable @Field(name = "last-name") String lastName;
@Nullable @Field(name = "current-location") GeoPoint location;
+
+ public Person() {}
+
+ public Person(@Nullable String id, @Nullable String lastName) {
+ this.id = id;
+ this.lastName = lastName;
+ }
+
+ public Person(@Nullable String id, @Nullable String lastName, @Nullable GeoPoint location) {
+ this.id = id;
+ this.lastName = lastName;
+ this.location = location;
+ }
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(@Nullable String lastName) {
+ this.lastName = lastName;
+ }
+
+ @Nullable
+ public GeoPoint getLocation() {
+ return location;
+ }
+
+ public void setLocation(@Nullable GeoPoint location) {
+ this.location = location;
+ }
}
static class EntityWithSeqNoPrimaryTerm {
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/SearchAsYouTypeTests.java b/src/test/java/org/springframework/data/elasticsearch/core/SearchAsYouTypeTests.java
index c03c3cd94..c04c30879 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/SearchAsYouTypeTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/SearchAsYouTypeTests.java
@@ -17,12 +17,6 @@ package org.springframework.data.elasticsearch.core;
import static org.assertj.core.api.Assertions.*;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -76,10 +70,10 @@ public class SearchAsYouTypeTests {
private void loadEntities() {
List indexQueries = new ArrayList<>();
- indexQueries.add(SearchAsYouTypeEntity.builder().id("1").name("test 1").suggest("test 1234").build().toIndex());
- indexQueries.add(SearchAsYouTypeEntity.builder().id("2").name("test 2").suggest("test 5678").build().toIndex());
- indexQueries.add(SearchAsYouTypeEntity.builder().id("3").name("test 3").suggest("asd 5678").build().toIndex());
- indexQueries.add(SearchAsYouTypeEntity.builder().id("4").name("test 4").suggest("not match").build().toIndex());
+ indexQueries.add(new SearchAsYouTypeEntity("1", "test 1", "test 1234").toIndex());
+ indexQueries.add(new SearchAsYouTypeEntity("2", "test 2", "test 5678").toIndex());
+ indexQueries.add(new SearchAsYouTypeEntity("3", "test 3", "asd 5678").toIndex());
+ indexQueries.add(new SearchAsYouTypeEntity("4", "test 4", "not match").toIndex());
IndexCoordinates index = IndexCoordinates.of("test-index-core-search-as-you-type");
operations.bulkIndex(indexQueries, index);
operations.indexOps(SearchAsYouTypeEntity.class).refresh();
@@ -109,9 +103,8 @@ public class SearchAsYouTypeTests {
.collect(Collectors.toList());
// then
- assertThat(result).hasSize(2);
- assertThat(result).contains(new SearchAsYouTypeEntity("1"));
- assertThat(result).contains(new SearchAsYouTypeEntity("2"));
+ List ids = result.stream().map(SearchAsYouTypeEntity::getId).collect(Collectors.toList());
+ assertThat(ids).containsExactlyInAnyOrder("1", "2");
}
@Test // DATAES-773
@@ -131,9 +124,8 @@ public class SearchAsYouTypeTests {
.collect(Collectors.toList());
// then
- assertThat(result).hasSize(2);
- assertThat(result).contains(new SearchAsYouTypeEntity("2"));
- assertThat(result).contains(new SearchAsYouTypeEntity("3"));
+ List ids = result.stream().map(SearchAsYouTypeEntity::getId).collect(Collectors.toList());
+ assertThat(ids).containsExactlyInAnyOrder("2", "3");
}
@Test // DATAES-773
@@ -153,18 +145,12 @@ public class SearchAsYouTypeTests {
.collect(Collectors.toList());
// then
- assertThat(result).hasSize(1);
- assertThat(result).contains(new SearchAsYouTypeEntity("4"));
+ assertThat(result.get(0).getId()).isEqualTo("4");
}
/**
* @author Aleksei Arsenev
*/
- @Data
- @Builder
- @NoArgsConstructor
- @AllArgsConstructor
- @EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Document(indexName = "test-index-core-search-as-you-type", replicas = 0, refreshInterval = "-1")
static class SearchAsYouTypeEntity {
@@ -172,17 +158,71 @@ public class SearchAsYouTypeTests {
this.id = id;
}
- @NonNull @Id @EqualsAndHashCode.Include private String id;
-
+ @Nullable @Id private String id;
@Nullable private String name;
-
@Nullable @Field(type = FieldType.Search_As_You_Type, maxShingleSize = 4) private String suggest;
+ public SearchAsYouTypeEntity() {
+ }
+
+ public SearchAsYouTypeEntity(String id, @Nullable String name, @Nullable String suggest) {
+ this.id = id;
+ this.name = name;
+ this.suggest = suggest;
+ }
+
public IndexQuery toIndex() {
IndexQuery indexQuery = new IndexQuery();
indexQuery.setId(getId());
indexQuery.setObject(this);
return indexQuery;
}
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
+
+ @Nullable
+ public String getSuggest() {
+ return suggest;
+ }
+
+ public void setSuggest(@Nullable String suggest) {
+ this.suggest = suggest;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ SearchAsYouTypeEntity that = (SearchAsYouTypeEntity) o;
+
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+ if (name != null ? !name.equals(that.name) : that.name != null) return false;
+ return suggest != null ? suggest.equals(that.suggest) : that.suggest == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (name != null ? name.hashCode() : 0);
+ result = 31 * result + (suggest != null ? suggest.hashCode() : 0);
+ return result;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/SourceFilterIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/SourceFilterIntegrationTests.java
index abcc79998..0bd7f4a18 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/SourceFilterIntegrationTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/SourceFilterIntegrationTests.java
@@ -17,11 +17,6 @@ package org.springframework.data.elasticsearch.core;
import static org.assertj.core.api.Assertions.*;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
import java.util.Collections;
import java.util.List;
@@ -39,6 +34,7 @@ import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.SourceFilter;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
+import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
/**
@@ -57,7 +53,12 @@ public class SourceFilterIntegrationTests {
indexOps.create();
indexOps.putMapping();
- operations.save(Entity.builder().id("42").field1("one").field2("two").field3("three").build());
+ Entity entity = new Entity();
+ entity.setId("42");
+ entity.setField1("one");
+ entity.setField2("two");
+ entity.setField3("three");
+ operations.save(entity);
}
@AfterEach
@@ -201,15 +202,47 @@ public class SourceFilterIntegrationTests {
assertThat(entity.getField3()).isNull();
}
- @Data
- @Builder
- @NoArgsConstructor
- @AllArgsConstructor
@Document(indexName = "sourcefilter-tests")
public static class Entity {
- @Id private String id;
- @Field(type = FieldType.Text) private String field1;
- @Field(type = FieldType.Text) private String field2;
- @Field(type = FieldType.Text) private String field3;
+ @Nullable @Id private String id;
+ @Nullable @Field(type = FieldType.Text) private String field1;
+ @Nullable @Field(type = FieldType.Text) private String field2;
+ @Nullable @Field(type = FieldType.Text) private String field3;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getField1() {
+ return field1;
+ }
+
+ public void setField1(@Nullable String field1) {
+ this.field1 = field1;
+ }
+
+ @Nullable
+ public String getField2() {
+ return field2;
+ }
+
+ public void setField2(@Nullable String field2) {
+ this.field2 = field2;
+ }
+
+ @Nullable
+ public String getField3() {
+ return field3;
+ }
+
+ public void setField3(@Nullable String field3) {
+ this.field3 = field3;
+ }
}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/aggregation/ElasticsearchTemplateAggregationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/aggregation/ElasticsearchTemplateAggregationTests.java
index 7b88efb8b..c60c23bf9 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/aggregation/ElasticsearchTemplateAggregationTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/aggregation/ElasticsearchTemplateAggregationTests.java
@@ -21,8 +21,6 @@ import static org.elasticsearch.search.aggregations.AggregationBuilders.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.Integer;
-import lombok.Data;
-
import java.lang.Integer;
import java.util.ArrayList;
import java.util.List;
@@ -50,6 +48,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.data.elasticsearch.utils.IndexInitializer;
+import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
/**
@@ -131,33 +130,79 @@ public class ElasticsearchTemplateAggregationTests {
assertThat(searchHits.hasSearchHits()).isFalse();
}
- /**
- * Simple type to test facets
- *
- * @author Artur Konczak
- * @author Mohsin Husen
- */
- @Data
@Document(indexName = "test-index-articles-core-aggregation", replicas = 0, refreshInterval = "-1")
static class ArticleEntity {
- @Id private String id;
- private String title;
- @Field(type = Text, fielddata = true) private String subject;
+ @Nullable @Id private String id;
+ @Nullable private String title;
+ @Nullable @Field(type = Text, fielddata = true) private String subject;
- @MultiField(mainField = @Field(type = Text),
+ @Nullable @MultiField(mainField = @Field(type = Text),
otherFields = {
@InnerField(suffix = "untouched", type = Text, store = true, fielddata = true, analyzer = "keyword"),
@InnerField(suffix = "sort", type = Text, store = true,
analyzer = "keyword") }) private List authors = new ArrayList<>();
- @Field(type = Integer, store = true) private List publishedYears = new ArrayList<>();
+ @Nullable @Field(type = Integer, store = true) private List publishedYears = new ArrayList<>();
- private int score;
+ @Nullable private int score;
public ArticleEntity(String id) {
this.id = id;
}
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(@Nullable String title) {
+ this.title = title;
+ }
+
+ @Nullable
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(@Nullable String subject) {
+ this.subject = subject;
+ }
+
+ @Nullable
+ public List getAuthors() {
+ return authors;
+ }
+
+ public void setAuthors(@Nullable List authors) {
+ this.authors = authors;
+ }
+
+ @Nullable
+ public List getPublishedYears() {
+ return publishedYears;
+ }
+
+ public void setPublishedYears(@Nullable List publishedYears) {
+ this.publishedYears = publishedYears;
+ }
+
+ public int getScore() {
+ return score;
+ }
+
+ public void setScore(int score) {
+ this.score = score;
+ }
}
/**
diff --git a/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java
index 8d20208a8..225102876 100644
--- a/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java
@@ -19,15 +19,6 @@ import static java.util.Collections.*;
import static org.assertj.core.api.Assertions.*;
import static org.skyscreamer.jsonassert.JSONAssert.*;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.RequiredArgsConstructor;
-import lombok.Setter;
-
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
@@ -156,10 +147,10 @@ public class MappingElasticsearchConverterUnitTests {
observatoryRoad.location = new Point(-118.3026284D, 34.118347D);
bigBunsCafe = new Place();
- bigBunsCafe.name = "Big Buns Cafe";
- bigBunsCafe.city = "Los Angeles";
- bigBunsCafe.street = "15 South Fremont Avenue";
- bigBunsCafe.location = new Point(-118.1545845D, 34.0945637D);
+ bigBunsCafe.setName("Big Buns Cafe");
+ bigBunsCafe.setCity("Los Angeles");
+ bigBunsCafe.setStreet("15 South Fremont Avenue");
+ bigBunsCafe.setLocation(new Point(-118.1545845D, 34.0945637D));
sarahAsMap = Document.create();
sarahAsMap.put("id", "sarah");
@@ -258,13 +249,11 @@ public class MappingElasticsearchConverterUnitTests {
@Test // DATAES-530
public void shouldMapObjectToJsonString() {
- // Given
+ Car car = new Car();
+ car.setModel(CAR_MODEL);
+ car.setName(CAR_NAME);
+ String jsonResult = mappingElasticsearchConverter.mapObject(car).toJson();
- // When
- String jsonResult = mappingElasticsearchConverter.mapObject(Car.builder().model(CAR_MODEL).name(CAR_NAME).build())
- .toJson();
-
- // Then
assertThat(jsonResult).isEqualTo(JSON_STRING);
}
@@ -307,19 +296,14 @@ public class MappingElasticsearchConverterUnitTests {
" ]\n" + //
"}\n"; //
- GeoEntity geoEntity = GeoEntity.builder().pointA(point).pointB(GeoPoint.fromPoint(point)).pointC(pointAsString)
- .pointD(pointAsArray).build();
- // when
+ GeoEntity geoEntity = new GeoEntity();
+ geoEntity.setPointA(point);
+ geoEntity.setPointB(GeoPoint.fromPoint(point));
+ geoEntity.setPointC(pointAsString);
+ geoEntity.setPointD(pointAsArray);
String jsonResult = mappingElasticsearchConverter.mapObject(geoEntity).toJson();
- // then
-
assertEquals(expected, jsonResult, false);
- // assertThat(jsonResult).contains(pointTemplate("pointA", point));
- // assertThat(jsonResult).contains(pointTemplate("pointB", point));
- // assertThat(jsonResult).contains(String.format(Locale.ENGLISH, "\"%s\":\"%s\"", "pointC", pointAsString));
- // assertThat(jsonResult)
- // .contains(String.format(Locale.ENGLISH, "\"%s\":[%.1f,%.1f]", "pointD", pointAsArray[0], pointAsArray[1]));
}
@Test // DATAES-530
@@ -327,10 +311,10 @@ public class MappingElasticsearchConverterUnitTests {
// given
Sample sample = new Sample();
- sample.readOnly = "readOnly";
- sample.property = "property";
- sample.javaTransientProperty = "javaTransient";
- sample.annotatedTransientProperty = "transient";
+ sample.setReadOnly("readOnly");
+ sample.setProperty("property");
+ sample.setJavaTransientProperty("javaTransient");
+ sample.setAnnotatedTransientProperty("transient");
// when
String result = mappingElasticsearchConverter.mapObject(sample).toJson();
@@ -360,8 +344,8 @@ public class MappingElasticsearchConverterUnitTests {
public void writesConcreteList() {
Person ginger = new Person();
- ginger.id = "ginger";
- ginger.gender = Gender.MAN;
+ ginger.setId("ginger");
+ ginger.setGender(Gender.MAN);
sarahConnor.coWorkers = Arrays.asList(kyleReese, ginger);
@@ -630,9 +614,9 @@ public class MappingElasticsearchConverterUnitTests {
@Test // DATAES-716
void shouldWriteLocalDate() throws JSONException {
Person person = new Person();
- person.id = "4711";
- person.firstName = "John";
- person.lastName = "Doe";
+ person.setId("4711");
+ person.setFirstName("John");
+ person.setLastName("Doe");
person.birthDate = LocalDate.of(2000, 8, 22);
person.gender = Gender.MAN;
@@ -703,8 +687,8 @@ public class MappingElasticsearchConverterUnitTests {
void writeEntityWithMapDataType() {
Notification notification = new Notification();
- notification.fromEmail = "from@email.com";
- notification.toEmail = "to@email.com";
+ notification.setFromEmail("from@email.com");
+ notification.setToEmail("to@email.com");
Map data = new HashMap<>();
data.put("documentType", "abc");
data.put("content", null);
@@ -920,23 +904,22 @@ public class MappingElasticsearchConverterUnitTests {
.of(Arrays.asList(GeoJsonPoint.of(12, 34), GeoJsonPolygon
.of(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12), new Point(12, 34)))));
- entity = GeoJsonEntity.builder() //
- .id("42") //
- .point1(GeoJsonPoint.of(12, 34)) //
- .point2(GeoJsonPoint.of(56, 78)) //
- .multiPoint1(GeoJsonMultiPoint.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))) //
- .multiPoint2(GeoJsonMultiPoint.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))) //
- .lineString1(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))) //
- .lineString2(GeoJsonLineString.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))) //
- .multiLineString1(multiLineString) //
- .multiLineString2(multiLineString) //
- .polygon1(geoJsonPolygon) //
- .polygon2(geoJsonPolygon) //
- .multiPolygon1(geoJsonMultiPolygon) //
- .multiPolygon2(geoJsonMultiPolygon) //
- .geometryCollection1(geoJsonGeometryCollection) //
- .geometryCollection2(geoJsonGeometryCollection) //
- .build();
+ entity = new GeoJsonEntity();
+ entity.setId("42");
+ entity.setPoint1(GeoJsonPoint.of(12, 34));
+ entity.setPoint2(GeoJsonPoint.of(56, 78));
+ entity.setMultiPoint1(GeoJsonMultiPoint.of(new Point(12, 34), new Point(56, 78), new Point(90, 12)));
+ entity.setMultiPoint2(GeoJsonMultiPoint.of(new Point(90, 12), new Point(56, 78), new Point(12, 34)));
+ entity.setLineString1(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12)));
+ entity.setLineString2(GeoJsonLineString.of(new Point(90, 12), new Point(56, 78), new Point(12, 34)));
+ entity.setMultiLineString1(multiLineString);
+ entity.setMultiLineString2(multiLineString);
+ entity.setPolygon1(geoJsonPolygon);
+ entity.setPolygon2(geoJsonPolygon);
+ entity.setMultiPolygon1(geoJsonMultiPolygon);
+ entity.setMultiPolygon2(geoJsonMultiPolygon);
+ entity.setGeometryCollection1(geoJsonGeometryCollection);
+ entity.setGeometryCollection2(geoJsonGeometryCollection);
}
@Test // DATAES-930
@@ -1205,37 +1188,233 @@ public class MappingElasticsearchConverterUnitTests {
}
public static class Sample {
-
@Nullable public @ReadOnlyProperty String readOnly;
@Nullable public @Transient String annotatedTransientProperty;
@Nullable public transient String javaTransientProperty;
@Nullable public String property;
+
+ @Nullable
+ public String getReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(@Nullable String readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ @Nullable
+ public String getAnnotatedTransientProperty() {
+ return annotatedTransientProperty;
+ }
+
+ public void setAnnotatedTransientProperty(@Nullable String annotatedTransientProperty) {
+ this.annotatedTransientProperty = annotatedTransientProperty;
+ }
+
+ @Nullable
+ public String getJavaTransientProperty() {
+ return javaTransientProperty;
+ }
+
+ public void setJavaTransientProperty(@Nullable String javaTransientProperty) {
+ this.javaTransientProperty = javaTransientProperty;
+ }
+
+ @Nullable
+ public String getProperty() {
+ return property;
+ }
+
+ public void setProperty(@Nullable String property) {
+ this.property = property;
+ }
}
- @Data
static class Person {
+ @Nullable @Id String id;
+ @Nullable String name;
+ @Nullable @Field(name = "first-name") String firstName;
+ @Nullable @Field(name = "last-name") String lastName;
+ @Nullable @Field(name = "birth-date", type = FieldType.Date, format = {},
+ pattern = "dd.MM.uuuu") LocalDate birthDate;
+ @Nullable Gender gender;
+ @Nullable Address address;
+ @Nullable List coWorkers;
+ @Nullable List inventoryList;
+ @Nullable Map shippingAddresses;
+ @Nullable Map inventoryMap;
- @Id String id;
- String name;
- @Field(name = "first-name") String firstName;
- @Field(name = "last-name") String lastName;
- @Field(name = "birth-date", type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") LocalDate birthDate;
- Gender gender;
- Address address;
+ @Nullable
+ public String getId() {
+ return id;
+ }
- List coWorkers;
- List inventoryList;
- Map shippingAddresses;
- Map inventoryMap;
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
+
+ @Nullable
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(@Nullable String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Nullable
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(@Nullable String lastName) {
+ this.lastName = lastName;
+ }
+
+ @Nullable
+ public LocalDate getBirthDate() {
+ return birthDate;
+ }
+
+ public void setBirthDate(@Nullable LocalDate birthDate) {
+ this.birthDate = birthDate;
+ }
+
+ @Nullable
+ public Gender getGender() {
+ return gender;
+ }
+
+ public void setGender(@Nullable Gender gender) {
+ this.gender = gender;
+ }
+
+ @Nullable
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(@Nullable Address address) {
+ this.address = address;
+ }
+
+ @Nullable
+ public List getCoWorkers() {
+ return coWorkers;
+ }
+
+ public void setCoWorkers(@Nullable List coWorkers) {
+ this.coWorkers = coWorkers;
+ }
+
+ @Nullable
+ public List getInventoryList() {
+ return inventoryList;
+ }
+
+ public void setInventoryList(@Nullable List inventoryList) {
+ this.inventoryList = inventoryList;
+ }
+
+ @Nullable
+ public Map getShippingAddresses() {
+ return shippingAddresses;
+ }
+
+ public void setShippingAddresses(@Nullable Map shippingAddresses) {
+ this.shippingAddresses = shippingAddresses;
+ }
+
+ @Nullable
+ public Map getInventoryMap() {
+ return inventoryMap;
+ }
+
+ public void setInventoryMap(@Nullable Map inventoryMap) {
+ this.inventoryMap = inventoryMap;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Person person = (Person) o;
+
+ if (id != null ? !id.equals(person.id) : person.id != null)
+ return false;
+ if (name != null ? !name.equals(person.name) : person.name != null)
+ return false;
+ if (firstName != null ? !firstName.equals(person.firstName) : person.firstName != null)
+ return false;
+ if (lastName != null ? !lastName.equals(person.lastName) : person.lastName != null)
+ return false;
+ if (birthDate != null ? !birthDate.equals(person.birthDate) : person.birthDate != null)
+ return false;
+ if (gender != person.gender)
+ return false;
+ if (address != null ? !address.equals(person.address) : person.address != null)
+ return false;
+ if (coWorkers != null ? !coWorkers.equals(person.coWorkers) : person.coWorkers != null)
+ return false;
+ if (inventoryList != null ? !inventoryList.equals(person.inventoryList) : person.inventoryList != null)
+ return false;
+ if (shippingAddresses != null ? !shippingAddresses.equals(person.shippingAddresses)
+ : person.shippingAddresses != null)
+ return false;
+ return inventoryMap != null ? inventoryMap.equals(person.inventoryMap) : person.inventoryMap == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (name != null ? name.hashCode() : 0);
+ result = 31 * result + (firstName != null ? firstName.hashCode() : 0);
+ result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
+ result = 31 * result + (birthDate != null ? birthDate.hashCode() : 0);
+ result = 31 * result + (gender != null ? gender.hashCode() : 0);
+ result = 31 * result + (address != null ? address.hashCode() : 0);
+ result = 31 * result + (coWorkers != null ? coWorkers.hashCode() : 0);
+ result = 31 * result + (inventoryList != null ? inventoryList.hashCode() : 0);
+ result = 31 * result + (shippingAddresses != null ? shippingAddresses.hashCode() : 0);
+ result = 31 * result + (inventoryMap != null ? inventoryMap.hashCode() : 0);
+ return result;
+ }
}
- @Data
- @Getter
- @Setter
static class LocalDatesEntity {
- @Id private String id;
- @Field(name = "dates", type = FieldType.Date, format = DateFormat.custom,
+ @Nullable @Id private String id;
+ @Nullable @Field(name = "dates", type = FieldType.Date, format = DateFormat.custom,
pattern = "dd.MM.uuuu") private List dates;
+
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ public void setId(@Nullable String id) {
+ this.id = id;
+ }
+
+ @Nullable
+ public List getDates() {
+ return dates;
+ }
+
+ public void setDates(@Nullable List dates) {
+ this.dates = dates;
+ }
}
enum Gender {
@@ -1258,89 +1437,314 @@ public class MappingElasticsearchConverterUnitTests {
String getLabel();
}
- @Getter
- @RequiredArgsConstructor
- @EqualsAndHashCode
static class Gun implements Inventory {
-
final String label;
final int shotsPerMagazine;
+ public Gun(@Nullable String label, int shotsPerMagazine) {
+ this.label = label;
+ this.shotsPerMagazine = shotsPerMagazine;
+ }
+
@Override
public String getLabel() {
return label;
}
+
+ public int getShotsPerMagazine() {
+ return shotsPerMagazine;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Gun gun = (Gun) o;
+
+ if (shotsPerMagazine != gun.shotsPerMagazine)
+ return false;
+ return label.equals(gun.label);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = label.hashCode();
+ result = 31 * result + shotsPerMagazine;
+ return result;
+ }
}
- @RequiredArgsConstructor
- @EqualsAndHashCode
static class Grenade implements Inventory {
-
final String label;
+ public Grenade(String label) {
+ this.label = label;
+ }
+
@Override
public String getLabel() {
return label;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof Grenade))
+ return false;
+
+ Grenade grenade = (Grenade) o;
+
+ return label.equals(grenade.label);
+ }
+
+ @Override
+ public int hashCode() {
+ return label.hashCode();
+ }
}
@TypeAlias("rifle")
- @EqualsAndHashCode
- @RequiredArgsConstructor
static class Rifle implements Inventory {
final String label;
final double weight;
final int maxShotsPerMagazine;
+ public Rifle(String label, double weight, int maxShotsPerMagazine) {
+ this.label = label;
+ this.weight = weight;
+ this.maxShotsPerMagazine = maxShotsPerMagazine;
+ }
+
@Override
public String getLabel() {
return label;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof Rifle))
+ return false;
+
+ Rifle rifle = (Rifle) o;
+
+ if (Double.compare(rifle.weight, weight) != 0)
+ return false;
+ if (maxShotsPerMagazine != rifle.maxShotsPerMagazine)
+ return false;
+ return label.equals(rifle.label);
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ long temp;
+ result = label.hashCode();
+ temp = Double.doubleToLongBits(weight);
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
+ result = 31 * result + maxShotsPerMagazine;
+ return result;
+ }
}
- @EqualsAndHashCode
- @RequiredArgsConstructor
static class ShotGun implements Inventory {
- final String label;
+ private final String label;
+
+ public ShotGun(String label) {
+ this.label = label;
+ }
@Override
public String getLabel() {
return label;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof ShotGun))
+ return false;
+
+ ShotGun shotGun = (ShotGun) o;
+
+ return label.equals(shotGun.label);
+ }
+
+ @Override
+ public int hashCode() {
+ return label.hashCode();
+ }
}
- @Data
static class Address {
+ @Nullable private Point location;
+ @Nullable private String street;
+ @Nullable private String city;
- Point location;
- String street;
- String city;
+ @Nullable
+ public Point getLocation() {
+ return location;
+ }
+
+ public void setLocation(@Nullable Point location) {
+ this.location = location;
+ }
+
+ @Nullable
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(@Nullable String street) {
+ this.street = street;
+ }
+
+ @Nullable
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(@Nullable String city) {
+ this.city = city;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof Address))
+ return false;
+
+ Address address = (Address) o;
+
+ if (location != null ? !location.equals(address.location) : address.location != null)
+ return false;
+ if (street != null ? !street.equals(address.street) : address.street != null)
+ return false;
+ return city != null ? city.equals(address.city) : address.city == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = location != null ? location.hashCode() : 0;
+ result = 31 * result + (street != null ? street.hashCode() : 0);
+ result = 31 * result + (city != null ? city.hashCode() : 0);
+ return result;
+ }
}
- @EqualsAndHashCode(callSuper = true)
- @Data
static class Place extends Address {
+ @Nullable private String name;
- String name;
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof Place))
+ return false;
+
+ Place place = (Place) o;
+
+ return name != null ? name.equals(place.name) : place.name == null;
+ }
+
+ @Override
+ public int hashCode() {
+ return name != null ? name.hashCode() : 0;
+ }
}
- @Data
static class Skynet {
+ @Nullable private Object object;
+ @Nullable private List