From e950084f993edea049c9dbd540515bd686b6066d Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 20 Jun 2023 11:02:46 +0200 Subject: [PATCH] Delombok test code. Closes #1398 --- ...syncOptimisticLockingIntegrationTests.java | 29 +- .../CassandraTemplateIntegrationTests.java | 373 +++++++++++++-- ...eleteOperationSupportIntegrationTests.java | 26 +- ...nsertOperationSupportIntegrationTests.java | 56 ++- ...electOperationSupportIntegrationTests.java | 109 +++-- ...pdateOperationSupportIntegrationTests.java | 49 +- .../OptimisticLockingIntegrationTests.java | 29 +- ...eleteOperationSupportIntegrationTests.java | 62 ++- ...nsertOperationSupportIntegrationTests.java | 55 ++- ...tiveOptimisticLockingIntegrationTests.java | 28 +- ...electOperationSupportIntegrationTests.java | 126 +++-- ...pdateOperationSupportIntegrationTests.java | 46 +- .../CassandraTypeMappingIntegrationTests.java | 58 ++- .../cassandra/core/convert/CounterEntity.java | 33 +- .../CustomConversionIntegrationTests.java | 67 ++- ...assandraConverterMappedTupleUnitTests.java | 25 +- ...ssandraConverterTupleIntegrationTests.java | 101 +++- ...CassandraConverterUDTIntegrationTests.java | 209 ++++++++- ...MappingCassandraConverterUDTUnitTests.java | 392 ++++++++++++++-- .../MappingCassandraConverterUnitTests.java | 210 ++++++--- .../core/convert/QueryMapperUnitTests.java | 57 +-- .../core/convert/SchemaFactoryUnitTests.java | 50 +- .../cassandra/core/convert/TimeEntity.java | 12 +- .../core/convert/UpdateMapperUnitTests.java | 73 ++- ...CassandraCompositePrimaryKeyUnitTests.java | 29 +- ...sistentEntityOrderPropertiesUnitTests.java | 50 +- .../CreateUserTypeIntegrationTests.java | 43 +- .../AuditingEntityCallbackUnitTests.java | 19 +- ...activeAuditingEntityCallbackUnitTests.java | 18 +- .../data/cassandra/domain/AddressType.java | 53 ++- .../cassandra/domain/AllPossibleTypes.java | 438 +++++++++++++++++- .../data/cassandra/domain/BookReference.java | 42 +- .../data/cassandra/domain/CompositeKey.java | 30 +- .../data/cassandra/domain/FlatGroup.java | 42 +- .../data/cassandra/domain/Group.java | 56 ++- .../data/cassandra/domain/GroupKey.java | 66 ++- .../data/cassandra/domain/Person.java | 156 ++++++- .../domain/TypeWithCompositeKey.java | 19 +- .../cassandra/domain/TypeWithKeyClass.java | 10 +- .../data/cassandra/domain/TypeWithMapId.java | 19 +- .../data/cassandra/domain/User.java | 50 +- .../data/cassandra/domain/UserToken.java | 65 ++- .../data/cassandra/domain/VersionedUser.java | 72 ++- .../BigIntParamIntegrationTests.java | 21 +- .../repository/DateKeyIntegrationTests.java | 21 +- .../repository/IntParamIntegrationTests.java | 21 +- .../QueryDerivationIntegrationTests.java | 89 +++- .../repository/conversion/Address.java | 62 ++- .../repository/conversion/Contact.java | 83 +++- .../repository/conversion/Phone.java | 28 +- .../entity/CorrelationEntity.java | 43 +- ...yMethodParameterTypesIntegrationTests.java | 4 +- .../mapid/SinglePrimaryKeyColumn.java | 26 +- .../SimpleCassandraRepositoryUnitTests.java | 25 +- ...eReactiveCassandraRepositoryUnitTests.java | 18 +- .../cassandra/support/CassandraVersion.java | 5 +- .../data/cassandra/support/CqlDataSet.java | 10 +- .../support/UserDefinedTypeBuilder.java | 105 ----- 58 files changed, 3373 insertions(+), 740 deletions(-) diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncOptimisticLockingIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncOptimisticLockingIntegrationTests.java index fe22b0f2d..d6c02725b 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncOptimisticLockingIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncOptimisticLockingIntegrationTests.java @@ -17,9 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Data; -import lombok.experimental.Wither; - import java.util.concurrent.Future; import org.junit.jupiter.api.BeforeEach; @@ -141,8 +138,6 @@ private static T getUninterruptibly(Future future) { } } - @Data - @Wither static class VersionedEntity { @Id final long id; @@ -161,5 +156,29 @@ private VersionedEntity(long id, long version, String name) { this.version = version; this.name = name; } + + public long getId() { + return this.id; + } + + public long getVersion() { + return this.version; + } + + public String getName() { + return this.name; + } + + public VersionedEntity withId(long id) { + return new VersionedEntity(id, this.version, this.name); + } + + public VersionedEntity withVersion(long version) { + return new VersionedEntity(this.id, version, this.name); + } + + public VersionedEntity withName(String name) { + return new VersionedEntity(this.id, this.version, name); + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java index 5e236ded7..3c7ee6159 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java @@ -20,9 +20,6 @@ import static org.junit.Assume.*; import static org.springframework.data.cassandra.core.query.Criteria.*; -import lombok.AllArgsConstructor; -import lombok.Data; - import java.time.Instant; import java.time.LocalDateTime; import java.time.LocalTime; @@ -67,6 +64,7 @@ import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; import org.springframework.data.util.Version; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlIdentifier; import com.datastax.oss.driver.api.core.uuid.Uuids; @@ -208,8 +206,8 @@ void shouldSelectProjectionWithCompositeKey() { TypeWithCompositeKey loadedEntity = loaded.get(0); assertThat(loadedEntity.getKey()).isNotNull(); - assertThat(loadedEntity.getKey().getFirstname()).isNotNull(); - assertThat(loadedEntity.getKey().getLastname()).isNull(); + assertThat(loadedEntity.getKey().firstname()).isNotNull(); + assertThat(loadedEntity.getKey().lastname()).isNull(); assertThat(loadedEntity.getComment()).isNotNull(); } @@ -799,37 +797,87 @@ void shouldPartiallyUpdateListOfMappedUdt() { template.update(Query.query(where("id").is("id-1")), update, WithMappedUdtList.class); WithMappedUdtList updated = template.selectOne(Query.query(where("id").is("id-1")), WithMappedUdtList.class); - assertThat(updated.getMappedUdts()).extracting(MappedUdt::getName).containsExactly("one", "replacement", "three"); + assertThat(updated.getMappedUdts()).extracting(MappedUdt::name).containsExactly("one", "replacement", "three"); } - @Data @UserDefinedType - static class MappedUdt { - - final String name; + record MappedUdt(String name) { } - @Data @Table static class WithMappedUdtList { @Id String id; List mappedUdts; + + public WithMappedUdtList() {} + + public String getId() { + return this.id; + } + + public List getMappedUdts() { + return this.mappedUdts; + } + + public void setId(String id) { + this.id = id; + } + + public void setMappedUdts(List mappedUdts) { + this.mappedUdts = mappedUdts; + } } - @Data static class TimeClass { @Id LocalTime id; LocalTime bar; + + public TimeClass() {} + + public LocalTime getId() { + return this.id; + } + + public LocalTime getBar() { + return this.bar; + } + + public void setId(LocalTime id) { + this.id = id; + } + + public void setBar(LocalTime bar) { + this.bar = bar; + } } - @Data - @AllArgsConstructor static class TypeWithCompositeKey { @PrimaryKey CompositeKey key; String comment; + + public TypeWithCompositeKey(CompositeKey key, String comment) { + this.key = key; + this.comment = comment; + } + + public CompositeKey getKey() { + return this.key; + } + + public String getComment() { + return this.comment; + } + + public void setKey(CompositeKey key) { + this.key = key; + } + + public void setComment(String comment) { + this.comment = comment; + } } interface WithCompositeKeyProjection { @@ -837,78 +885,349 @@ interface WithCompositeKeyProjection { CompositeKey getKey(); } - @Data @PrimaryKeyClass - @AllArgsConstructor - static class CompositeKey { + record CompositeKey( + + @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) String firstname, + @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) String lastname) { - @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) String firstname; - @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) String lastname; } - @Data static class WithNullableEmbeddedType { @Id String id; @Embedded.Nullable EmbeddedWithSimpleTypes nested; + + public WithNullableEmbeddedType() {} + + public String getId() { + return this.id; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setId(String id) { + this.id = id; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + WithNullableEmbeddedType that = (WithNullableEmbeddedType) o; + + if (!ObjectUtils.nullSafeEquals(id, that.id)) { + return false; + } + return ObjectUtils.nullSafeEquals(nested, that.nested); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(nested); + return result; + } } - @Data static class WithPrefixedNullableEmbeddedType { @Id String id; @Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested; + + public WithPrefixedNullableEmbeddedType() {} + + public String getId() { + return this.id; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setId(String id) { + this.id = id; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + WithPrefixedNullableEmbeddedType that = (WithPrefixedNullableEmbeddedType) o; + + if (!ObjectUtils.nullSafeEquals(id, that.id)) { + return false; + } + return ObjectUtils.nullSafeEquals(nested, that.nested); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(nested); + return result; + } } - @Data static class WithEmptyEmbeddedType { @Id String id; @Embedded.Empty EmbeddedWithSimpleTypes nested; + + public WithEmptyEmbeddedType() {} + + public String getId() { + return this.id; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setId(String id) { + this.id = id; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } } - @Data static class EmbeddedWithSimpleTypes { String firstname; Integer age; + + public EmbeddedWithSimpleTypes() {} + + public String getFirstname() { + return this.firstname; + } + + public Integer getAge() { + return this.age; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setAge(Integer age) { + this.age = age; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + EmbeddedWithSimpleTypes that = (EmbeddedWithSimpleTypes) o; + + if (!ObjectUtils.nullSafeEquals(firstname, that.firstname)) { + return false; + } + return ObjectUtils.nullSafeEquals(age, that.age); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(firstname); + result = 31 * result + ObjectUtils.nullSafeHashCode(age); + return result; + } } - @Data static class OuterWithNullableEmbeddedType { @Id String id; UDTWithNullableEmbeddedType udtValue; + + public OuterWithNullableEmbeddedType() {} + + public String getId() { + return this.id; + } + + public UDTWithNullableEmbeddedType getUdtValue() { + return this.udtValue; + } + + public void setId(String id) { + this.id = id; + } + + public void setUdtValue(UDTWithNullableEmbeddedType udtValue) { + this.udtValue = udtValue; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + OuterWithNullableEmbeddedType that = (OuterWithNullableEmbeddedType) o; + + if (!ObjectUtils.nullSafeEquals(id, that.id)) { + return false; + } + return ObjectUtils.nullSafeEquals(udtValue, that.udtValue); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(udtValue); + return result; + } } - @Data static class OuterWithPrefixedNullableEmbeddedType { @Id String id; UDTWithPrefixedNullableEmbeddedType udtValue; + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + OuterWithPrefixedNullableEmbeddedType that = (OuterWithPrefixedNullableEmbeddedType) o; + + if (!ObjectUtils.nullSafeEquals(id, that.id)) { + return false; + } + return ObjectUtils.nullSafeEquals(udtValue, that.udtValue); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(udtValue); + return result; + } } @UserDefinedType - @Data static class UDTWithNullableEmbeddedType { String value; @Embedded.Nullable EmbeddedWithSimpleTypes nested; + + public UDTWithNullableEmbeddedType() {} + + public String getValue() { + return this.value; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setValue(String value) { + this.value = value; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + UDTWithNullableEmbeddedType that = (UDTWithNullableEmbeddedType) o; + + if (!ObjectUtils.nullSafeEquals(value, that.value)) { + return false; + } + return ObjectUtils.nullSafeEquals(nested, that.nested); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(value); + result = 31 * result + ObjectUtils.nullSafeHashCode(nested); + return result; + } } @UserDefinedType - @Data static class UDTWithPrefixedNullableEmbeddedType { String value; @Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested; + + public UDTWithPrefixedNullableEmbeddedType() {} + + public String getValue() { + return this.value; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setValue(String value) { + this.value = value; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + UDTWithPrefixedNullableEmbeddedType that = (UDTWithPrefixedNullableEmbeddedType) o; + + if (!ObjectUtils.nullSafeEquals(value, that.value)) { + return false; + } + return ObjectUtils.nullSafeEquals(nested, that.nested); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(value); + result = 31 * result + ObjectUtils.nullSafeHashCode(nested); + return result; + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableDeleteOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableDeleteOperationSupportIntegrationTests.java index dc4fc22c1..1f1877dd5 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableDeleteOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableDeleteOperationSupportIntegrationTests.java @@ -19,8 +19,6 @@ import static org.springframework.data.cassandra.core.query.Criteria.*; import static org.springframework.data.cassandra.core.query.Query.*; -import lombok.Data; - import java.util.Collections; import org.junit.jupiter.api.BeforeEach; @@ -87,15 +85,31 @@ void removeAllMatchingWithAlternateDomainTypeAndCollection() { assertThat(this.template.select(Query.empty(), Person.class)).isEmpty(); } - @Data @Table static class Person { @Id String id; @Indexed String firstname; + + public Person() {} + + public String getId() { + return this.id; + } + + public String getFirstname() { + return this.firstname; + } + + public void setId(String id) { + this.id = id; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + } - @Data - static class Jedi { - @Column("firstname") String name; + record Jedi(@Column("firstname") String name) { } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableInsertOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableInsertOperationSupportIntegrationTests.java index 3e0e21ac1..292ef5557 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableInsertOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableInsertOperationSupportIntegrationTests.java @@ -17,8 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Data; - import java.util.Collections; import org.junit.jupiter.api.BeforeEach; @@ -28,6 +26,7 @@ import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -102,11 +101,62 @@ void insertOneWithOptions() { assertThat(template.selectOneById(han.id, Person.class)).isEqualTo(han); } - @Data @Table static class Person { @Id String id; @Indexed String firstname; @Indexed String lastname; + + public Person() {} + + public String getId() { + return this.id; + } + + public String getFirstname() { + return this.firstname; + } + + public String getLastname() { + return this.lastname; + } + + public void setId(String id) { + this.id = id; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Person person = (Person) o; + + if (!ObjectUtils.nullSafeEquals(id, person.id)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) { + return false; + } + return ObjectUtils.nullSafeEquals(lastname, person.lastname); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(firstname); + result = 31 * result + ObjectUtils.nullSafeHashCode(lastname); + return result; + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableSelectOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableSelectOperationSupportIntegrationTests.java index 8b16dd641..92317f1eb 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableSelectOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableSelectOperationSupportIntegrationTests.java @@ -19,10 +19,6 @@ import static org.springframework.data.cassandra.core.query.Criteria.*; import static org.springframework.data.cassandra.core.query.Query.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; @@ -38,6 +34,7 @@ import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.util.ObjectUtils; /** * Integration tests for {@link ExecutableSelectOperationSupport}. @@ -126,8 +123,7 @@ void findAllBy() { @Test // DATACASS-485 void findAllByWithCollectionUsingMappingInformation() { - assertThat(this.template.query(Jedi.class).inTable("person").all()) - .isNotEmpty().hasOnlyElementsOfType(Jedi.class); + assertThat(this.template.query(Jedi.class).inTable("person").all()).isNotEmpty().hasOnlyElementsOfType(Jedi.class); } @Test // DATACASS-485 @@ -138,8 +134,7 @@ void findAllByWithCollection() { @Test // DATACASS-485 void findAllByWithProjection() { - assertThat(this.template.query(Person.class).as(Jedi.class).all()) - .hasOnlyElementsOfType(Jedi.class).isNotEmpty(); + assertThat(this.template.query(Person.class).as(Jedi.class).all()).hasOnlyElementsOfType(Jedi.class).isNotEmpty(); } @Test // DATACASS-485 @@ -182,11 +177,8 @@ void findByReturningFirstValueForManyResults() { @Test // DATACASS-485 void findByReturningFirstValueAsClosedInterfaceProjection() { - PersonProjection result = this.template - .query(Person.class) - .as(PersonProjection.class) - .matching(query(where("firstname").is("han")).withAllowFiltering()) - .firstValue(); + PersonProjection result = this.template.query(Person.class).as(PersonProjection.class) + .matching(query(where("firstname").is("han")).withAllowFiltering()).firstValue(); assertThat(result).isInstanceOf(PersonProjection.class); assertThat(result.getFirstname()).isEqualTo("han"); @@ -195,11 +187,8 @@ void findByReturningFirstValueAsClosedInterfaceProjection() { @Test // DATACASS-485 void findByReturningFirstValueAsOpenInterfaceProjection() { - PersonSpELProjection result = this.template - .query(Person.class) - .as(PersonSpELProjection.class) - .matching(query(where("firstname").is("han")).withAllowFiltering()) - .firstValue(); + PersonSpELProjection result = this.template.query(Person.class).as(PersonSpELProjection.class) + .matching(query(where("firstname").is("han")).withAllowFiltering()).firstValue(); assertThat(result).isInstanceOf(PersonSpELProjection.class); assertThat(result.getName()).isEqualTo("han"); @@ -232,8 +221,7 @@ void streamAllWithProjection() { @Test // DATACASS-485 void streamAllReturningResultsAsClosedInterfaceProjection() { - TerminatingSelect operation = - this.template.query(Person.class).as(PersonProjection.class); + TerminatingSelect operation = this.template.query(Person.class).as(PersonProjection.class); assertThat(operation.stream()) // .hasSize(2) // @@ -246,8 +234,8 @@ void streamAllReturningResultsAsClosedInterfaceProjection() { @Test // DATACASS-485 void streamAllReturningResultsAsOpenInterfaceProjection() { - TerminatingSelect operation = - this.template.query(Person.class).as(PersonSpELProjection.class); + TerminatingSelect operation = this.template.query(Person.class) + .as(PersonSpELProjection.class); assertThat(operation.stream()) // .hasSize(2) // @@ -277,8 +265,8 @@ void countShouldReturnNrOfElementsInCollectionWhenNoQueryPresent() { @Test // DATACASS-485 void countShouldReturnNrOfElementsMatchingQuery() { - assertThat(this.template.query(Person.class).matching(query(where("firstname").is(luke.getFirstname())) - .withAllowFiltering()).count()).isEqualTo(1); + assertThat(this.template.query(Person.class) + .matching(query(where("firstname").is(luke.getFirstname())).withAllowFiltering()).count()).isEqualTo(1); } @Test // DATACASS-485 @@ -319,12 +307,63 @@ private static Query querySpock() { private interface Contact {} - @Data @Table static class Person implements Contact { @Id String id; @Indexed String firstname; @Indexed String lastname; + + public Person() {} + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Person person = (Person) o; + + if (!ObjectUtils.nullSafeEquals(id, person.id)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) { + return false; + } + return ObjectUtils.nullSafeEquals(lastname, person.lastname); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(firstname); + result = 31 * result + ObjectUtils.nullSafeHashCode(lastname); + return result; + } } private interface PersonProjection { @@ -332,18 +371,24 @@ private interface PersonProjection { } public interface PersonSpELProjection { - @Value("#{target.firstname}") String getName(); + @Value("#{target.firstname}") + String getName(); } - @Data static class Human { @Id String id; + + public Human() {} + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } } - @Data - @AllArgsConstructor - @NoArgsConstructor - static class Jedi { - @Column("firstname") String name; + record Jedi(@Column("firstname") String name) { } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableUpdateOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableUpdateOperationSupportIntegrationTests.java index df31425d0..64026c11a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableUpdateOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableUpdateOperationSupportIntegrationTests.java @@ -20,8 +20,6 @@ import static org.springframework.data.cassandra.core.query.Query.*; import static org.springframework.data.cassandra.core.query.Update.*; -import lombok.Data; - import java.util.Collections; import org.junit.jupiter.api.BeforeEach; @@ -33,6 +31,7 @@ import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -118,15 +117,53 @@ private Query queryPerson(Person person) { return query(where("id").is(person.getId())); } - @Data @Table static class Person { @Id String id; @Indexed String firstname; + + public Person() {} + + public String getId() { + return this.id; + } + + public String getFirstname() { + return this.firstname; + } + + public void setId(String id) { + this.id = id; + } + + public void setFirstname(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 (!ObjectUtils.nullSafeEquals(id, person.id)) { + return false; + } + return ObjectUtils.nullSafeEquals(firstname, person.firstname); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(firstname); + return result; + } } - @Data - static class Jedi { - @Column("firstname") String name; + record Jedi(@Column("firstname") String name) { + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/OptimisticLockingIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/OptimisticLockingIntegrationTests.java index 329fc5665..eb55267dd 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/OptimisticLockingIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/OptimisticLockingIntegrationTests.java @@ -17,9 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Data; -import lombok.experimental.Wither; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.dao.OptimisticLockingFailureException; @@ -127,8 +124,6 @@ void deleteForOutdatedEntityShouldFail() { assertThat(loaded).isNotNull(); } - @Data - @Wither static class VersionedEntity { @Id final long id; @@ -147,5 +142,29 @@ private VersionedEntity(long id, long version, String name) { this.version = version; this.name = name; } + + public long getId() { + return this.id; + } + + public long getVersion() { + return this.version; + } + + public String getName() { + return this.name; + } + + public VersionedEntity withId(long id) { + return new VersionedEntity(id, this.version, this.name); + } + + public VersionedEntity withVersion(long version) { + return new VersionedEntity(this.id, version, this.name); + } + + public VersionedEntity withName(String name) { + return new VersionedEntity(this.id, this.version, name); + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveDeleteOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveDeleteOperationSupportIntegrationTests.java index d0835c80a..d88e3a3fc 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveDeleteOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveDeleteOperationSupportIntegrationTests.java @@ -18,7 +18,6 @@ import static org.springframework.data.cassandra.core.query.Criteria.*; import static org.springframework.data.cassandra.core.query.Query.*; -import lombok.Data; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -34,6 +33,7 @@ import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -59,8 +59,7 @@ void setUp() { admin.dropTable(true, CqlIdentifier.fromCql("person")); admin.createTable(true, CqlIdentifier.fromCql("person"), - ExecutableInsertOperationSupportIntegrationTests.Person.class, - Collections.emptyMap()); + ExecutableInsertOperationSupportIntegrationTests.Person.class, Collections.emptyMap()); han = new Person(); han.firstname = "han"; @@ -77,10 +76,7 @@ void setUp() { @Test // DATACASS-485 void removeAllMatching() { - Mono writeResult = this.template - .delete(Person.class) - .matching(query(where("id").is(han.id))) - .all(); + Mono writeResult = this.template.delete(Person.class).matching(query(where("id").is(han.id))).all(); writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete(); } @@ -88,24 +84,60 @@ void removeAllMatching() { @Test // DATACASS-485 void removeAllMatchingWithAlternateDomainTypeAndCollection() { - Mono writeResult = this.template - .delete(Jedi.class).inTable("person") - .matching(query(where("id").in(han.id, luke.id))) - .all(); + Mono writeResult = this.template.delete(Jedi.class).inTable("person") + .matching(query(where("id").in(han.id, luke.id))).all(); writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete(); template.select(Query.empty(), Person.class).as(StepVerifier::create).verifyComplete(); } - @Data @Table static class Person { @Id String id; @Indexed String firstname; + + public Person() {} + + public String getId() { + return this.id; + } + + public String getFirstname() { + return this.firstname; + } + + public void setId(String id) { + this.id = id; + } + + public void setFirstname(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 (!ObjectUtils.nullSafeEquals(id, person.id)) { + return false; + } + return ObjectUtils.nullSafeEquals(firstname, person.firstname); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(firstname); + return result; + } } - @Data - static class Jedi { - @Column("firstname") String name; + record Jedi(@Column("firstname") String name) { + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveInsertOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveInsertOperationSupportIntegrationTests.java index 23c6b0dae..15c7c734a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveInsertOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveInsertOperationSupportIntegrationTests.java @@ -17,7 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Data; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -31,6 +30,7 @@ import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -114,11 +114,62 @@ void insertOneWithOptions() { template.selectOneById(han.id, Person.class).as(StepVerifier::create).expectNext(han).verifyComplete(); } - @Data @Table static class Person { @Id String id; @Indexed String firstname; @Indexed String lastname; + + public Person() {} + + public String getId() { + return this.id; + } + + public String getFirstname() { + return this.firstname; + } + + public String getLastname() { + return this.lastname; + } + + public void setId(String id) { + this.id = id; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Person person = (Person) o; + + if (!ObjectUtils.nullSafeEquals(id, person.id)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) { + return false; + } + return ObjectUtils.nullSafeEquals(lastname, person.lastname); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(firstname); + result = 31 * result + ObjectUtils.nullSafeHashCode(lastname); + return result; + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveOptimisticLockingIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveOptimisticLockingIntegrationTests.java index 83b3fc28f..a95756e2c 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveOptimisticLockingIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveOptimisticLockingIntegrationTests.java @@ -17,8 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Data; -import lombok.experimental.Wither; import reactor.test.StepVerifier; import org.junit.jupiter.api.BeforeEach; @@ -149,8 +147,6 @@ void deleteForOutdatedEntityShouldFail() { .verifyComplete(); } - @Data - @Wither static class VersionedEntity { @Id final long id; @@ -169,5 +165,29 @@ private VersionedEntity(long id, long version, String name) { this.version = version; this.name = name; } + + public long getId() { + return this.id; + } + + public long getVersion() { + return this.version; + } + + public String getName() { + return this.name; + } + + public VersionedEntity withId(long id) { + return new VersionedEntity(id, this.version, this.name); + } + + public VersionedEntity withVersion(long version) { + return new VersionedEntity(this.id, version, this.name); + } + + public VersionedEntity withName(String name) { + return new VersionedEntity(this.id, this.version, name); + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveSelectOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveSelectOperationSupportIntegrationTests.java index 6c4760dca..72a492fc0 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveSelectOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveSelectOperationSupportIntegrationTests.java @@ -19,9 +19,6 @@ import static org.springframework.data.cassandra.core.query.Criteria.*; import static org.springframework.data.cassandra.core.query.Query.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -39,6 +36,7 @@ import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.util.ObjectUtils; /** * Integration tests for {@link ExecutableSelectOperationSupport}. @@ -105,9 +103,7 @@ void findAll() { Flux result = this.template.query(Person.class).all(); result.collectList().as(StepVerifier::create) - .assertNext(actual -> - assertThat(actual).containsExactlyInAnyOrder(han, luke) - ).verifyComplete(); + .assertNext(actual -> assertThat(actual).containsExactlyInAnyOrder(han, luke)).verifyComplete(); } @Test // DATACASS-485 @@ -124,9 +120,7 @@ void findAllWithProjection() { Flux result = this.template.query(Person.class).as(Jedi.class).all(); result.collectList().as(StepVerifier::create) - .assertNext(actual -> - assertThat(actual).hasOnlyElementsOfType(Jedi.class).hasSize(2) - ).verifyComplete(); + .assertNext(actual -> assertThat(actual).hasOnlyElementsOfType(Jedi.class).hasSize(2)).verifyComplete(); } @Test // DATACASS-485 @@ -135,9 +129,8 @@ void findByReturningAllValuesAsClosedInterfaceProjection() { Flux result = this.template.query(Person.class).as(PersonProjection.class).all(); result.collectList().as(StepVerifier::create) - .assertNext(actual -> - assertThat(actual).hasOnlyElementsOfType(PersonProjection.class).hasSize(2) - ).verifyComplete(); + .assertNext(actual -> assertThat(actual).hasOnlyElementsOfType(PersonProjection.class).hasSize(2)) + .verifyComplete(); } @Test // DATACASS-485 @@ -154,9 +147,7 @@ void findAllByWithCollectionUsingMappingInformation() { Flux result = this.template.query(Jedi.class).inTable("person").all(); result.collectList().as(StepVerifier::create) - .assertNext(actual -> - assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class) - ).verifyComplete(); + .assertNext(actual -> assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class)).verifyComplete(); } @Test // DATACASS-485 @@ -173,9 +164,7 @@ void findAllByWithProjection() { Flux result = this.template.query(Person.class).as(Jedi.class).all(); result.collectList().as(StepVerifier::create) - .assertNext(actual -> - assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class) - ).verifyComplete(); + .assertNext(actual -> assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class)).verifyComplete(); } @Test // DATACASS-485 @@ -215,19 +204,14 @@ void findByReturningFirstForManyResults() { Mono result = this.template.query(Person.class).first(); - result.as(StepVerifier::create).assertNext(actual -> - assertThat(actual).isIn(han, luke) - ).verifyComplete(); + result.as(StepVerifier::create).assertNext(actual -> assertThat(actual).isIn(han, luke)).verifyComplete(); } @Test // DATACASS-485 void findByReturningFirstAsClosedInterfaceProjection() { - Mono result = this.template - .query(Person.class) - .as(PersonProjection.class) - .matching(query(where("firstname").is("han")).withAllowFiltering()) - .first(); + Mono result = this.template.query(Person.class).as(PersonProjection.class) + .matching(query(where("firstname").is("han")).withAllowFiltering()).first(); result.as(StepVerifier::create).assertNext(actual -> { assertThat(actual).isInstanceOf(PersonProjection.class); @@ -238,11 +222,8 @@ void findByReturningFirstAsClosedInterfaceProjection() { @Test // DATACASS-485 void findByReturningFirstAsOpenInterfaceProjection() { - Mono result = this.template - .query(Person.class) - .as(PersonSpELProjection.class) - .matching(query(where("firstname").is("han")).withAllowFiltering()) - .first(); + Mono result = this.template.query(Person.class).as(PersonSpELProjection.class) + .matching(query(where("firstname").is("han")).withAllowFiltering()).first(); result.as(StepVerifier::create).assertNext(actual -> { assertThat(actual).isInstanceOf(PersonSpELProjection.class); @@ -261,10 +242,8 @@ void countShouldReturnNumberOfElementsInCollectionWhenNoQueryPresent() { @Test // DATACASS-485 void countShouldReturnNrOfElementsMatchingQuery() { - Mono count = this.template - .query(Person.class) - .matching(query(where("firstname").is(luke.getFirstname())).withAllowFiltering()) - .count(); + Mono count = this.template.query(Person.class) + .matching(query(where("firstname").is(luke.getFirstname())).withAllowFiltering()).count(); count.as(StepVerifier::create).expectNext(1L).verifyComplete(); } @@ -309,9 +288,7 @@ void returnsTargetObjectDirectlyIfProjectionInterfaceIsImplemented() { Flux result = this.template.query(Person.class).as(Contact.class).all(); result.collectList().as(StepVerifier::create) - .assertNext(actual -> - assertThat(actual).allMatch(it -> it instanceof Person) - ).verifyComplete(); + .assertNext(actual -> assertThat(actual).allMatch(it -> it instanceof Person)).verifyComplete(); } private static Query queryLuke() { @@ -324,12 +301,63 @@ private static Query querySpock() { private interface Contact {} - @Data @Table static class Person implements Contact { @Id String id; @Indexed String firstname; @Indexed String lastname; + + public Person() {} + + public String getId() { + return this.id; + } + + public String getFirstname() { + return this.firstname; + } + + public String getLastname() { + return this.lastname; + } + + public void setId(String id) { + this.id = id; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Person person = (Person) o; + + if (!ObjectUtils.nullSafeEquals(id, person.id)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) { + return false; + } + return ObjectUtils.nullSafeEquals(lastname, person.lastname); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(firstname); + result = 31 * result + ObjectUtils.nullSafeHashCode(lastname); + return result; + } } private interface PersonProjection { @@ -341,21 +369,27 @@ public interface PersonSpELProjection { String getName(); } - @Data static class Human { @Id String id; + + public Human() {} + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } } - @Data - @AllArgsConstructor - @NoArgsConstructor - static class Jedi { - @Column("firstname") String name; + record Jedi(@Column("firstname") String name) { + } - @Data static class Sith { String rank; + } interface PlanetProjection { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveUpdateOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveUpdateOperationSupportIntegrationTests.java index a0b434c23..d59f4fc69 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveUpdateOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveUpdateOperationSupportIntegrationTests.java @@ -20,7 +20,6 @@ import static org.springframework.data.cassandra.core.query.Query.*; import static org.springframework.data.cassandra.core.query.Update.*; -import lombok.Data; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -36,6 +35,7 @@ import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -115,15 +115,51 @@ private Query queryHan() { return query(where("id").is(han.getId())); } - @Data @Table static class Person { @Id String id; @Indexed String firstname; + + public String getId() { + return this.id; + } + + public String getFirstname() { + return this.firstname; + } + + public void setId(String id) { + this.id = id; + } + + public void setFirstname(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 (!ObjectUtils.nullSafeEquals(id, person.id)) { + return false; + } + return ObjectUtils.nullSafeEquals(firstname, person.firstname); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(firstname); + return result; + } } - @Data - static class Jedi { - @Column("firstname") String name; + record Jedi(@Column("firstname") String name) { + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CassandraTypeMappingIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CassandraTypeMappingIntegrationTests.java index 545451d5f..6249d3af0 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CassandraTypeMappingIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CassandraTypeMappingIntegrationTests.java @@ -18,10 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.junit.Assume.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.math.BigDecimal; import java.math.BigInteger; import java.net.InetAddress; @@ -512,7 +508,7 @@ void shouldReadAndWriteTime() { TimeEntity loaded = operations.selectOneById(id, TimeEntity.class); - assertThat(loaded.getTime()).isEqualTo(time); + assertThat(loaded.time()).isEqualTo(time); } @Test // DATACASS-296 @@ -640,20 +636,64 @@ public enum Condition { MINT } - @Data - @AllArgsConstructor static class WithDuration { @Id String id; Duration duration; CqlDuration cqlDuration; + + public WithDuration(String id, Duration duration, CqlDuration cqlDuration) { + this.id = id; + this.duration = duration; + this.cqlDuration = cqlDuration; + } + + public String getId() { + return this.id; + } + + public Duration getDuration() { + return this.duration; + } + + public CqlDuration getCqlDuration() { + return this.cqlDuration; + } + + public void setId(String id) { + this.id = id; + } + + public void setDuration(Duration duration) { + this.duration = duration; + } + + public void setCqlDuration(CqlDuration cqlDuration) { + this.cqlDuration = cqlDuration; + } + } - @Data - @NoArgsConstructor static class ListOfTuples { @Id String id; List tuples; + + public String getId() { + return this.id; + } + + public List getTuples() { + return this.tuples; + } + + public void setId(String id) { + this.id = id; + } + + public void setTuples(List tuples) { + this.tuples = tuples; + } + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CounterEntity.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CounterEntity.java index 5ff2711d0..453247d11 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CounterEntity.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CounterEntity.java @@ -15,11 +15,6 @@ */ package org.springframework.data.cassandra.core.convert; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.data.cassandra.core.mapping.CassandraType; import org.springframework.data.cassandra.core.mapping.PrimaryKey; import org.springframework.data.cassandra.core.mapping.Table; @@ -28,11 +23,31 @@ * @author Mark Paluch */ @Table -@Data -@NoArgsConstructor -@RequiredArgsConstructor public class CounterEntity { - @PrimaryKey @NonNull private String id; + @PrimaryKey private String id; @CassandraType(type = CassandraType.Name.COUNTER) private long count; + + public CounterEntity(String id) { + this.id = id; + } + + public CounterEntity() {} + + public String getId() { + return this.id; + } + + public long getCount() { + return this.count; + } + + public void setId(String id) { + this.id = id; + } + + public void setCount(long count) { + this.count = count; + } + } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CustomConversionIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CustomConversionIntegrationTests.java index bd9f9cde1..6c1ec0ba5 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CustomConversionIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/CustomConversionIntegrationTests.java @@ -17,10 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -210,7 +206,6 @@ private static MappingCassandraConverter createConverter(Consumer friends; Set people; + + public Employee() {} + + public String getId() { + return this.id; + } + + public Person getPerson() { + return this.person; + } + + public List getFriends() { + return this.friends; + } + + public Set getPeople() { + return this.people; + } + + public void setId(String id) { + this.id = id; + } + + public void setPerson(Person person) { + this.person = person; + } + + public void setFriends(List friends) { + this.friends = friends; + } + + public void setPeople(Set people) { + this.people = people; + } + } - @Data - @AllArgsConstructor - @NoArgsConstructor static class Person { String firstname; String lastname; + + public Person(String firstname, String lastname) { + this.firstname = firstname; + this.lastname = lastname; + } + + public Person() {} + + public String getFirstname() { + return this.firstname; + } + + public String getLastname() { + return this.lastname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + } /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterMappedTupleUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterMappedTupleUnitTests.java index 485199557..1d2281f10 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterMappedTupleUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterMappedTupleUnitTests.java @@ -18,9 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.springframework.data.cassandra.test.util.RowMockUtil.*; -import lombok.AllArgsConstructor; -import lombok.Data; - import java.util.LinkedHashMap; import java.util.Map; @@ -80,12 +77,12 @@ void shouldReadMappedTupleValue() { Person person = this.mappingCassandraConverter.read(Person.class, rowMock); assertThat(person).isNotNull(); - assertThat(person.getName()).isEqualTo("Jon Doe"); + assertThat(person.name()).isEqualTo("Jon Doe"); - MappedTuple tuple = person.getTuple(); + MappedTuple tuple = person.tuple(); - assertThat(tuple.getName()).isEqualTo("hello"); - assertThat(tuple.getPosition()).isEqualTo(1); + assertThat(tuple.name()).isEqualTo("hello"); + assertThat(tuple.position()).isEqualTo(1); } @Test // DATACASS-523 @@ -102,18 +99,12 @@ void shouldWriteMappedTuple() { assertThat(tupleValue.getFormattedContents()).contains("('hello',1)"); } - @Data - @AllArgsConstructor - private static class Person { - String name; - MappedTuple tuple; + record Person(String name, MappedTuple tuple) { + } @Tuple - @Data - @AllArgsConstructor - private static class MappedTuple { - @Element(0) String name; - @Element(1) int position; + record MappedTuple(@Element(0) String name, @Element(1) int position) { + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterTupleIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterTupleIntegrationTests.java index 9b56dd8f7..c19fa5337 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterTupleIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterTupleIntegrationTests.java @@ -17,8 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Data; - import java.util.Arrays; import java.util.Collections; import java.util.Currency; @@ -149,9 +147,7 @@ void shouldInsertRowWithComplexTuple() { person.setId("foo"); - AddressUserType userType = new AddressUserType(); - - userType.setZip("myzip"); + AddressUserType userType = new AddressUserType("myzip"); MappedTuple tuple = new MappedTuple(); @@ -251,7 +247,6 @@ void shouldReadTupleWithValue() { assertThat(mappedTuple.myName).isEqualTo("bar"); } - @Data @Table static class Person { @@ -263,15 +258,94 @@ static class Person { List mappedTuples; Map mapOfTuples; Map mapOfTupleValues; + + public String getId() { + return this.id; + } + + public TupleValue getTupleValue() { + return this.tupleValue; + } + + public MappedTuple getMappedTuple() { + return this.mappedTuple; + } + + public MappedTupleWithValue getMappedTupleWithValue() { + return this.mappedTupleWithValue; + } + + public List getMappedTuples() { + return this.mappedTuples; + } + + public Map getMapOfTuples() { + return this.mapOfTuples; + } + + public Map getMapOfTupleValues() { + return this.mapOfTupleValues; + } + + public void setId(String id) { + this.id = id; + } + + public void setTupleValue(TupleValue tupleValue) { + this.tupleValue = tupleValue; + } + + public void setMappedTuple(MappedTuple mappedTuple) { + this.mappedTuple = mappedTuple; + } + + public void setMappedTupleWithValue(MappedTupleWithValue mappedTupleWithValue) { + this.mappedTupleWithValue = mappedTupleWithValue; + } + + public void setMappedTuples(List mappedTuples) { + this.mappedTuples = mappedTuples; + } + + public void setMapOfTuples(Map mapOfTuples) { + this.mapOfTuples = mapOfTuples; + } + + public void setMapOfTupleValues(Map mapOfTupleValues) { + this.mapOfTupleValues = mapOfTupleValues; + } } - @Data @Tuple static class MappedTuple { @Element(0) AddressUserType addressUserType; @Element(1) List currency; @Element(2) String name; + + public AddressUserType getAddressUserType() { + return addressUserType; + } + + public void setAddressUserType(AddressUserType addressUserType) { + this.addressUserType = addressUserType; + } + + public List getCurrency() { + return currency; + } + + public void setCurrency(List currency) { + this.currency = currency; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } @Tuple @@ -290,9 +364,20 @@ public MappedTupleWithValue(AddressUserType addressUserType, List curr } @UserDefinedType("address") - @Data static class AddressUserType { String zip; + + public AddressUserType(String zip) { + this.zip = zip; + } + + public String getZip() { + return zip; + } + + public void setZip(String zip) { + this.zip = zip; + } } private static class StringToCurrencyConverter implements Converter { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUDTIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUDTIntegrationTests.java index 3580ab9b2..b2425bf25 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUDTIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUDTIntegrationTests.java @@ -17,10 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; - import java.util.Arrays; import java.util.Currency; import java.util.List; @@ -42,6 +38,7 @@ import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlIdentifier; import com.datastax.oss.driver.api.core.CqlSession; @@ -221,64 +218,163 @@ void shouldReadUdtInMap() { } @Table - @Getter - @AllArgsConstructor private static class Bank { @Id String id; Currency currency; List otherCurrencies; + + public Bank(String id, Currency currency, List otherCurrencies) { + this.id = id; + this.currency = currency; + this.otherCurrencies = otherCurrencies; + } + + public String getId() { + return this.id; + } + + public Currency getCurrency() { + return this.currency; + } + + public List getOtherCurrencies() { + return this.otherCurrencies; + } } - @Data @Table public static class Money { @Id private Currency currency; + + public Money() {} + + public Currency getCurrency() { + return this.currency; + } + + public void setCurrency(Currency currency) { + this.currency = currency; + } + } @Table - @AllArgsConstructor - @Getter public static class MoneyTransfer { @Id String id; private Currency currency; + + public MoneyTransfer(String id, Currency currency) { + this.id = id; + this.currency = currency; + } + + public String getId() { + return this.id; + } + + public Currency getCurrency() { + return this.currency; + } } @Table - @Getter - @AllArgsConstructor private static class Car { @Id String id; Engine engine; + + public Car(String id, Engine engine) { + this.id = id; + this.engine = engine; + } + + public String getId() { + return this.id; + } + + public Engine getEngine() { + return this.engine; + } } @UserDefinedType - @Getter - @AllArgsConstructor private static class Engine { Manufacturer manufacturer; + + public Engine(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + } + + public Manufacturer getManufacturer() { + return this.manufacturer; + } } @UserDefinedType - @Data - @AllArgsConstructor private static class Manufacturer { String name; + + public Manufacturer(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Manufacturer that = (Manufacturer) o; + + return ObjectUtils.nullSafeEquals(name, that.name); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(name); + } } @Table - @Data - @AllArgsConstructor private static class Supplier { @Id String id; Map> acceptedCurrencies; + + public Supplier(String id, Map> acceptedCurrencies) { + this.id = id; + this.acceptedCurrencies = acceptedCurrencies; + } + + public String getId() { + return this.id; + } + + public Map> getAcceptedCurrencies() { + return this.acceptedCurrencies; + } + + public void setId(String id) { + this.id = id; + } + + public void setAcceptedCurrencies(Map> acceptedCurrencies) { + this.acceptedCurrencies = acceptedCurrencies; + } } - @Data @Table public static class AddressBook { @@ -287,28 +383,99 @@ public static class AddressBook { private AddressUserType currentaddress; private List previousaddresses; private UdtValue alternate; + + public String getId() { + return this.id; + } + + public AddressUserType getCurrentaddress() { + return this.currentaddress; + } + + public List getPreviousaddresses() { + return this.previousaddresses; + } + + public UdtValue getAlternate() { + return this.alternate; + } + + public void setId(String id) { + this.id = id; + } + + public void setCurrentaddress(AddressUserType currentaddress) { + this.currentaddress = currentaddress; + } + + public void setPreviousaddresses(List previousaddresses) { + this.previousaddresses = previousaddresses; + } + } - @Data @Table public static class WithUdtId { @Id private UdtValue id; + + public WithUdtId() {} + + public UdtValue getId() { + return this.id; + } + + public void setId(UdtValue id) { + this.id = id; + } + } - @Data @Table public static class WithMappedUdtId { @Id private AddressUserType id; + + public AddressUserType getId() { + return this.id; + } + + public void setId(AddressUserType id) { + this.id = id; + } + } @UserDefinedType("address") - @Data public static class AddressUserType { String zip; String city; List streetLines; + + public String getZip() { + return this.zip; + } + + public String getCity() { + return this.city; + } + + public List getStreetLines() { + return this.streetLines; + } + + public void setZip(String zip) { + this.zip = zip; + } + + public void setCity(String city) { + this.city = city; + } + + public void setStreetLines(List streetLines) { + this.streetLines = streetLines; + } + } private static class UDTToCurrencyConverter implements Converter { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUDTUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUDTUnitTests.java index d9cbd4e24..a63bf67cb 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUDTUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUDTUnitTests.java @@ -19,10 +19,6 @@ import static org.mockito.Mockito.*; import static org.springframework.data.cassandra.test.util.RowMockUtil.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; - import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -47,6 +43,7 @@ import org.springframework.data.cassandra.core.mapping.*; import org.springframework.data.cassandra.support.UserDefinedTypeBuilder; import org.springframework.data.cassandra.test.util.RowMockUtil; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlIdentifier; import com.datastax.oss.driver.api.core.cql.Row; @@ -67,8 +64,7 @@ class MappingCassandraConverterUDTUnitTests { @Mock UserTypeResolver userTypeResolver; private com.datastax.oss.driver.api.core.type.UserDefinedType manufacturer = UserDefinedTypeBuilder - .forName("manufacturer") - .withField("name", DataTypes.TEXT).withField("displayname", DataTypes.TEXT).build(); + .forName("manufacturer").withField("name", DataTypes.TEXT).withField("displayname", DataTypes.TEXT).build(); private com.datastax.oss.driver.api.core.type.UserDefinedType engine = UserDefinedTypeBuilder.forName("engine") .withField("manufacturer", manufacturer).build(); @@ -323,6 +319,7 @@ void shouldWriteUdtListWithCustomConversion() { assertThat(statement.getQuery()).isEqualTo("INSERT INTO bank (othercurrencies) VALUES ([{currency:'EUR'}])"); } + @Test // DATACASS-487, DATACASS-623 void shouldReadMappedUdtInMap() { @@ -454,8 +451,7 @@ void readPrefixedEmbeddedType() { rowMock = RowMockUtil.newRowMock(column("id", "id-1", DataTypes.TEXT), column("udtvalue", udtValue, withprefixednullableembeddedtype)); - OuterWithPrefixedNullableEmbeddedType target = converter - .read(OuterWithPrefixedNullableEmbeddedType.class, rowMock); + OuterWithPrefixedNullableEmbeddedType target = converter.read(OuterWithPrefixedNullableEmbeddedType.class, rowMock); assertThat(target.getId()).isEqualTo("id-1"); assertThat(target.udtValue).isNotNull(); assertThat(target.udtValue.value).isEqualTo("value-string"); @@ -493,85 +489,254 @@ void shouldWriteMapWithTypeHintToUdtValue() { } @Table - @Getter - @AllArgsConstructor private static class Car { @Id String id; Engine engine; + + public Car(String id, Engine engine) { + this.id = id; + this.engine = engine; + } + + public String getId() { + return this.id; + } + + public Engine getEngine() { + return this.engine; + } } @UserDefinedType - @Getter - @AllArgsConstructor private static class Engine { Manufacturer manufacturer; + + public Engine(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + } + + public Manufacturer getManufacturer() { + return this.manufacturer; + } } @UserDefinedType - @Data - @AllArgsConstructor private static class Manufacturer { String name; @ReadOnlyProperty String displayName; + + public Manufacturer(String name, String displayName) { + this.name = name; + this.displayName = displayName; + } + + public String getName() { + return this.name; + } + + public String getDisplayName() { + return this.displayName; + } + + public void setName(String name) { + this.name = name; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Manufacturer that = (Manufacturer) o; + + if (!ObjectUtils.nullSafeEquals(name, that.name)) { + return false; + } + return ObjectUtils.nullSafeEquals(displayName, that.displayName); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(name); + result = 31 * result + ObjectUtils.nullSafeHashCode(displayName); + return result; + } } - @Data - @AllArgsConstructor private static class Currency { String currency; + + public Currency(String currency) { + this.currency = currency; + } + + public String getCurrency() { + return this.currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Currency currency1 = (Currency) o; + + return ObjectUtils.nullSafeEquals(currency, currency1.currency); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(currency); + } } - @Data - @AllArgsConstructor private static class Supplier { Map> acceptedCurrencies; + + public Supplier(Map> acceptedCurrencies) { + this.acceptedCurrencies = acceptedCurrencies; + } + + public Map> getAcceptedCurrencies() { + return this.acceptedCurrencies; + } + + public void setAcceptedCurrencies(Map> acceptedCurrencies) { + this.acceptedCurrencies = acceptedCurrencies; + } } - @Data static class OuterWithNullableEmbeddedType { @Id String id; WithNullableEmbeddedType udtValue; + + public String getId() { + return this.id; + } + + public WithNullableEmbeddedType getUdtValue() { + return this.udtValue; + } + + public void setId(String id) { + this.id = id; + } + + public void setUdtValue(WithNullableEmbeddedType udtValue) { + this.udtValue = udtValue; + } } - @Data static class OuterWithPrefixedNullableEmbeddedType { @Id String id; WithPrefixedNullableEmbeddedType udtValue; + + public String getId() { + return this.id; + } + + public WithPrefixedNullableEmbeddedType getUdtValue() { + return this.udtValue; + } + + public void setId(String id) { + this.id = id; + } + + public void setUdtValue(WithPrefixedNullableEmbeddedType udtValue) { + this.udtValue = udtValue; + } } @UserDefinedType - @Data static class WithNullableEmbeddedType { String value; @Embedded.Nullable EmbeddedWithSimpleTypes nested; + + public String getValue() { + return this.value; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setValue(String value) { + this.value = value; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } } @UserDefinedType - @Data static class WithPrefixedNullableEmbeddedType { String value; @Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested; + + public String getValue() { + return this.value; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setValue(String value) { + this.value = value; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } } @UserDefinedType - @Data static class WithEmptyEmbeddedType { String value; @Embedded.Empty EmbeddedWithSimpleTypes nested; + + public String getValue() { + return this.value; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setValue(String value) { + this.value = value; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } } - @Data static class EmbeddedWithSimpleTypes { String firstname; @@ -584,9 +749,16 @@ public String getFirstname() { public Integer getAge() { return age; } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setAge(Integer age) { + this.age = age; + } } - @Data @Table public static class AddressBook { @@ -595,75 +767,223 @@ public static class AddressBook { private AddressUserType currentaddress; private List previousaddresses; private UdtValue alternate; + + public String getId() { + return this.id; + } + + public AddressUserType getCurrentaddress() { + return this.currentaddress; + } + + public List getPreviousaddresses() { + return this.previousaddresses; + } + + public UdtValue getAlternate() { + return this.alternate; + } + + public void setId(String id) { + this.id = id; + } + + public void setCurrentaddress(AddressUserType currentaddress) { + this.currentaddress = currentaddress; + } + + public void setPreviousaddresses(List previousaddresses) { + this.previousaddresses = previousaddresses; + } + + public void setAlternate(UdtValue alternate) { + this.alternate = alternate; + } } - @Data @Table public static class WithUdtId { @Id private UdtValue id; + + public UdtValue getId() { + return this.id; + } + + public void setId(UdtValue id) { + this.id = id; + } } - @Data @Table public static class WithMappedUdtId { @Id private AddressUserType id; + + public AddressUserType getId() { + return this.id; + } + + public void setId(AddressUserType id) { + this.id = id; + } } @UserDefinedType("address") - @Data public static class AddressUserType { String zip; String city; List streetLines; + + public String getZip() { + return this.zip; + } + + public String getCity() { + return this.city; + } + + public List getStreetLines() { + return this.streetLines; + } + + public void setZip(String zip) { + this.zip = zip; + } + + public void setCity(String city) { + this.city = city; + } + + public void setStreetLines(List streetLines) { + this.streetLines = streetLines; + } } @Table - @Getter - @AllArgsConstructor private static class Bank { @Id String id; Currency currency; List otherCurrencies; + + public Bank(String id, Currency currency, List otherCurrencies) { + this.id = id; + this.currency = currency; + this.otherCurrencies = otherCurrencies; + } + + public String getId() { + return this.id; + } + + public Currency getCurrency() { + return this.currency; + } + + public List getOtherCurrencies() { + return this.otherCurrencies; + } } - @Data @Table public static class Money { @Id private Currency currency; + + public Currency getCurrency() { + return this.currency; + } + + public void setCurrency(Currency currency) { + this.currency = currency; + } } - @Data @Table public static class WithCompositePrimaryKey { @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String id; @PrimaryKeyColumn(ordinal = 1) AddressUserType addressUserType; + + public String getId() { + return this.id; + } + + public AddressUserType getAddressUserType() { + return this.addressUserType; + } + + public void setId(String id) { + this.id = id; + } + + public void setAddressUserType(AddressUserType addressUserType) { + this.addressUserType = addressUserType; + } } - @Data @Table public static class WithCompositePrimaryKeyClassWithUdt { @PrimaryKey CompositePrimaryKeyClassWithUdt id; + + public CompositePrimaryKeyClassWithUdt getId() { + return this.id; + } + + public void setId(CompositePrimaryKeyClassWithUdt id) { + this.id = id; + } } - @Data @PrimaryKeyClass public static class CompositePrimaryKeyClassWithUdt { @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String id; @PrimaryKeyColumn(ordinal = 1) AddressUserType addressUserType; @PrimaryKeyColumn(ordinal = 2) Currency currency; + + public String getId() { + return this.id; + } + + public AddressUserType getAddressUserType() { + return this.addressUserType; + } + + public Currency getCurrency() { + return this.currency; + } + + public void setId(String id) { + this.id = id; + } + + public void setAddressUserType(AddressUserType addressUserType) { + this.addressUserType = addressUserType; + } + + public void setCurrency(Currency currency) { + this.currency = currency; + } } @Table - @AllArgsConstructor - @Getter public static class MoneyTransfer { @Id String id; private Currency currency; + + public MoneyTransfer(String id, Currency currency) { + this.id = id; + this.currency = currency; + } + + public String getId() { + return this.id; + } + + public Currency getCurrency() { + return this.currency; + } } private static class UDTToCurrencyConverter implements Converter { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUnitTests.java index 5fd2a6c8e..fba22f5a3 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverterUnitTests.java @@ -19,13 +19,6 @@ import static org.springframework.data.cassandra.core.mapping.BasicMapId.*; import static org.springframework.data.cassandra.test.util.RowMockUtil.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.RequiredArgsConstructor; -import lombok.ToString; - import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; @@ -36,18 +29,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -60,19 +42,8 @@ import org.springframework.data.annotation.ReadOnlyProperty; import org.springframework.data.annotation.Transient; import org.springframework.data.cassandra.core.cql.PrimaryKeyType; -import org.springframework.data.cassandra.core.mapping.BasicMapId; -import org.springframework.data.cassandra.core.mapping.CassandraMappingContext; -import org.springframework.data.cassandra.core.mapping.CassandraType; +import org.springframework.data.cassandra.core.mapping.*; import org.springframework.data.cassandra.core.mapping.Column; -import org.springframework.data.cassandra.core.mapping.Element; -import org.springframework.data.cassandra.core.mapping.Embedded; -import org.springframework.data.cassandra.core.mapping.MapId; -import org.springframework.data.cassandra.core.mapping.PrimaryKey; -import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; -import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; -import org.springframework.data.cassandra.core.mapping.Table; -import org.springframework.data.cassandra.core.mapping.Tuple; -import org.springframework.data.cassandra.core.mapping.UserDefinedType; import org.springframework.data.cassandra.domain.AllPossibleTypes; import org.springframework.data.cassandra.domain.CompositeKey; import org.springframework.data.cassandra.domain.TypeWithCompositeKey; @@ -85,6 +56,7 @@ import org.springframework.data.projection.EntityProjection; import org.springframework.data.projection.EntityProjectionIntrospector; import org.springframework.data.projection.SpelAwareProxyProjectionFactory; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlIdentifier; import com.datastax.oss.driver.api.core.cql.Row; @@ -981,8 +953,8 @@ void shouldConsiderNestedProjections() { WithMappedTupleDtoProjection result = this.mappingCassandraConverter.project(projection, rowMock); - assertThat(result.getFirstname()).isEqualTo("Heisenberg"); - assertThat(result.getTuple().getOne()).isEqualTo("One"); + assertThat(result.firstname()).isEqualTo("Heisenberg"); + assertThat(result.tuple().getOne()).isEqualTo("One"); } @Test // GH-1202 @@ -1007,9 +979,9 @@ void shouldCreateDtoProjectionsThroughConstructor() { TupleAndNameProjection result = this.mappingCassandraConverter.project(projection, rowMock); - assertThat(result.getName().getFirstname()).isEqualTo("Heisenberg"); - assertThat(result.getTuple().zero).isEqualTo("Zero"); - assertThat(result.getTuple().one).isEqualTo("One"); + assertThat(result.name().firstname()).isEqualTo("Heisenberg"); + assertThat(result.tuple().zero).isEqualTo("Zero"); + assertThat(result.tuple().one).isEqualTo("One"); } private static List getValues(Map statement) { @@ -1089,19 +1061,16 @@ private void setCondition(Condition condition) { } @PrimaryKeyClass - @RequiredArgsConstructor - @lombok.Value - public static class EnumAndDateCompositePrimaryKey implements Serializable { - - @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) private final Condition condition; + record EnumAndDateCompositePrimaryKey( + @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) Condition condition, + @PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.PARTITIONED) java.time.LocalDate localDate) + implements + Serializable { - @PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.PARTITIONED) private final java.time.LocalDate localDate; } - @RequiredArgsConstructor - public static class TypeWithEnumAndLocalDateKey { + record TypeWithEnumAndLocalDateKey(@PrimaryKey EnumAndDateCompositePrimaryKey id) { - @PrimaryKey private final EnumAndDateCompositePrimaryKey id; } @Table @@ -1150,10 +1119,13 @@ private static class CompositeKeyWithPropertyAccessors { } @Table - @RequiredArgsConstructor public static class TableWithCompositeKeyViaConstructor { @PrimaryKey private final CompositeKeyWithPropertyAccessors key; + + public TableWithCompositeKeyViaConstructor(CompositeKeyWithPropertyAccessors key) { + this.key = key; + } } @Table @@ -1169,15 +1141,19 @@ private static class TypeWithLocalDate { } /** - * Uses Cassandra's {@link Name#DATE} which maps by default to {@link LocalDate} + * Uses Cassandra's {@link CassandraType.Name#DATE} which maps by default to {@link LocalDate} */ @Table - @AllArgsConstructor public static class TypeWithLocalDateMappedToDate { @PrimaryKey private String id; @CassandraType(type = CassandraType.Name.DATE) java.time.LocalDate localDate; + + public TypeWithLocalDateMappedToDate(String id, LocalDate localDate) { + this.id = id; + this.localDate = localDate; + } } @Table @@ -1256,27 +1232,18 @@ private static class WithMappedTuple { TupleWithElementAnnotationInConstructor tuple; } - @lombok.Value - private static class Name { - String firstname; - } - - @Data - private static class WithMappedTupleDtoProjection { + private record Name(String firstname) { - String firstname; - TupleProjection tuple; } - @lombok.Value - private static class TupleAndNameProjection { + record WithMappedTupleDtoProjection(String firstname, TupleProjection tuple) { + } - @Embedded.Nullable Name name; + private record TupleAndNameProjection(@Embedded.Nullable Name name, TupleWithElementAnnotationInConstructor tuple) { - TupleWithElementAnnotationInConstructor tuple; } - private static interface TupleProjection { + private interface TupleProjection { String getZero(); @@ -1297,39 +1264,96 @@ public TupleWithElementAnnotationInConstructor(@Element(2) String firstname) { } } - @ToString static class WithNullableEmbeddedType { String id; @Embedded.Nullable EmbeddedWithSimpleTypes nested; + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(getClass().getSimpleName()); + sb.append(" [id='").append(id).append('\''); + sb.append(", nested=").append(nested); + sb.append(']'); + return sb.toString(); + } } - @ToString static class WithPrefixedNullableEmbeddedType { String id; @Embedded.Nullable("prefix") EmbeddedWithSimpleTypes nested; + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(getClass().getSimpleName()); + sb.append(" [id='").append(id).append('\''); + sb.append(", nested=").append(nested); + sb.append(']'); + return sb.toString(); + } } - @ToString static class WithEmptyEmbeddedType { String id; @Embedded.Empty EmbeddedWithSimpleTypes nested; + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(getClass().getSimpleName()); + sb.append(" [id='").append(id).append('\''); + sb.append(", nested=").append(nested); + sb.append(']'); + return sb.toString(); + } } - @ToString - @EqualsAndHashCode - @NoArgsConstructor - @AllArgsConstructor static class EmbeddedWithSimpleTypes { String firstname; Integer age; @Transient String displayName; + + public EmbeddedWithSimpleTypes() {} + + public EmbeddedWithSimpleTypes(String firstname, Integer age, String displayName) { + this.firstname = firstname; + this.age = age; + this.displayName = displayName; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + EmbeddedWithSimpleTypes that = (EmbeddedWithSimpleTypes) o; + + if (!ObjectUtils.nullSafeEquals(firstname, that.firstname)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(age, that.age)) { + return false; + } + return ObjectUtils.nullSafeEquals(displayName, that.displayName); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(firstname); + result = 31 * result + ObjectUtils.nullSafeHashCode(age); + result = 31 * result + ObjectUtils.nullSafeHashCode(displayName); + return result; + } } @Test // DATACASS-167 @@ -1500,7 +1524,6 @@ interface BookProjection { String getName(); } - @Data static class Book { @Id String id; @@ -1509,9 +1532,31 @@ static class Book { Author author = new Author(); + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Author getAuthor() { + return author; + } + + public void setAuthor(Author author) { + this.author = author; + } } - @Data @UserDefinedType static class Author { @@ -1521,5 +1566,28 @@ static class Author { String lastName; + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/QueryMapperUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/QueryMapperUnitTests.java index b8f8ad062..b71fc416a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/QueryMapperUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/QueryMapperUnitTests.java @@ -19,9 +19,6 @@ import static org.mockito.Mockito.*; import static org.springframework.data.domain.Sort.Order.*; -import lombok.AllArgsConstructor; -import lombok.Data; - import java.time.LocalDate; import java.time.LocalTime; import java.util.Collection; @@ -82,18 +79,16 @@ public class QueryMapperUnitTests { private QueryMapper queryMapper; - private final com.datastax.oss.driver.api.core.type.UserDefinedType userType = - UserDefinedTypeBuilder.forName("address") - .withField("street", DataTypes.TEXT) - .build(); + private final com.datastax.oss.driver.api.core.type.UserDefinedType userType = UserDefinedTypeBuilder + .forName("address").withField("street", DataTypes.TEXT).build(); @Mock UserTypeResolver userTypeResolver; @BeforeEach void before() { - CassandraCustomConversions customConversions = - new CassandraCustomConversions(Collections.singletonList(CurrencyConverter.INSTANCE)); + CassandraCustomConversions customConversions = new CassandraCustomConversions( + Collections.singletonList(CurrencyConverter.INSTANCE)); when(userTypeResolver.resolveType(any(CqlIdentifier.class))).thenReturn(userType); @@ -291,8 +286,8 @@ void shouldCreateSelectExpression() { void shouldCreateSelectExpressionWithTTL() { List selectors = queryMapper - .getMappedSelectors(Columns.from("number", "foo").ttl("firstName"), personPersistentEntity) - .stream().map(Selector::toString).collect(Collectors.toList()); + .getMappedSelectors(Columns.from("number", "foo").ttl("firstName"), personPersistentEntity).stream() + .map(Selector::toString).collect(Collectors.toList()); assertThat(selectors).contains("number").contains("foo").contains("TTL(first_name)"); } @@ -300,8 +295,8 @@ void shouldCreateSelectExpressionWithTTL() { @Test // DATACASS-343 void shouldIncludeColumnsSelectExpressionWithTTL() { - List selectors = - queryMapper.getMappedColumnNames(Columns.from("number", "foo").ttl("firstName"), personPersistentEntity); + List selectors = queryMapper.getMappedColumnNames(Columns.from("number", "foo").ttl("firstName"), + personPersistentEntity); assertThat(selectors).contains(CqlIdentifier.fromCql("number"), CqlIdentifier.fromCql("foo")).hasSize(2); } @@ -377,16 +372,15 @@ void shouldMapTime() { Filter filter = Filter.from(Criteria.where("localTime").gt(time)); - Filter mappedFilter = this.queryMapper. getMappedObject(filter, this.personPersistentEntity); + Filter mappedFilter = this.queryMapper.getMappedObject(filter, this.personPersistentEntity); assertThat(mappedFilter).contains(Criteria.where("localtime").gt(time)); } @Test // DATACASS-523 void referencingTupleElementsInQueryShouldFail() { - assertThatIllegalArgumentException() - .isThrownBy(() -> this.queryMapper.getMappedObject(Filter.from(Criteria.where("tuple.zip").is("123")), - this.personPersistentEntity)); + assertThatIllegalArgumentException().isThrownBy(() -> this.queryMapper + .getMappedObject(Filter.from(Criteria.where("tuple.zip").is("123")), this.personPersistentEntity)); } @Test // DATACASS-167 @@ -456,26 +450,21 @@ static class MyPrimaryKeyClass { @PrimaryKeyColumn long foo; @PrimaryKeyColumn long bar; - } @Tuple - @AllArgsConstructor - static class MappedTuple { - @Element(0) String zip; + record MappedTuple(@Element(0) String zip) { } @UserDefinedType - @AllArgsConstructor - static class Address { - String street; + record Address(String street) { + } enum State { Active, Inactive } - @Data static class WithNullableEmbeddedType { @Id String id; @@ -483,7 +472,6 @@ static class WithNullableEmbeddedType { @Embedded.Nullable EmbeddedWithSimpleTypes nested; } - @Data static class WithPrefixedNullableEmbeddedType { @Id String id; @@ -491,10 +479,25 @@ static class WithPrefixedNullableEmbeddedType { @Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested; } - @Data static class EmbeddedWithSimpleTypes { String firstname; Integer age; + + public String getFirstname() { + return this.firstname; + } + + public Integer getAge() { + return this.age; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setAge(Integer age) { + this.age = age; + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/SchemaFactoryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/SchemaFactoryUnitTests.java index 9896acf94..fc1642e3f 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/SchemaFactoryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/SchemaFactoryUnitTests.java @@ -20,10 +20,6 @@ import static org.mockito.Mockito.*; import static org.springframework.data.cassandra.core.mapping.CassandraType.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; @@ -143,7 +139,8 @@ void shouldCreateTableForMappedAndConvertedColumn() { this.mappingContext.setUserTypeResolver(typeName -> mappedudt); - CassandraPersistentEntity persistentEntity = this.mappingContext.getRequiredPersistentEntity(WithMapOfMixedTypes.class); + CassandraPersistentEntity persistentEntity = this.mappingContext + .getRequiredPersistentEntity(WithMapOfMixedTypes.class); CreateTableSpecification tableSpecification = schemaFactory.getCreateTableSpecificationFor(persistentEntity); @@ -286,7 +283,8 @@ private static CreateIndexSpecification getSpecificationFor(String column, private static class IndexedType { - @PrimaryKeyColumn("first_name") @Indexed("my_index") String firstname; + @PrimaryKeyColumn("first_name") + @Indexed("my_index") String firstname; @Indexed List phoneNumbers; } @@ -295,7 +293,8 @@ private static class IndexedType { static class CompositeKeyWithIndex { @PrimaryKeyColumn(value = "first_name", type = PrimaryKeyType.PARTITIONED) String firstname; - @PrimaryKeyColumn("last_name") @Indexed("my_index") String lastname; + @PrimaryKeyColumn("last_name") + @Indexed("my_index") String lastname; } private static class CompositeKeyEntity { @@ -311,18 +310,20 @@ private static class InvalidMapIndex { @Test // DATACASS-506 void shouldCreatedUserTypeSpecificationsWithAnnotatedTypeName() { - assertThat(schemaFactory.getCreateUserTypeSpecificationFor(mappingContext.getRequiredPersistentEntity(WithUdt.class))) - .isNotNull(); - assertThat(schemaFactory.getCreateUserTypeSpecificationFor(mappingContext.getRequiredPersistentEntity(Nested.class))) - .isNotNull(); + assertThat( + schemaFactory.getCreateUserTypeSpecificationFor(mappingContext.getRequiredPersistentEntity(WithUdt.class))) + .isNotNull(); + assertThat( + schemaFactory.getCreateUserTypeSpecificationFor(mappingContext.getRequiredPersistentEntity(Nested.class))) + .isNotNull(); } @Test // DATACASS-172 void createTableForComplexPrimaryKeyShouldFail() { try { - schemaFactory - .getCreateTableSpecificationFor(mappingContext.getRequiredPersistentEntity(EntityWithComplexPrimaryKeyColumn.class)); + schemaFactory.getCreateTableSpecificationFor( + mappingContext.getRequiredPersistentEntity(EntityWithComplexPrimaryKeyColumn.class)); fail("Missing MappingException"); } catch (MappingException e) { assertThat(e).hasMessageContaining( @@ -330,7 +331,8 @@ void createTableForComplexPrimaryKeyShouldFail() { } try { - schemaFactory.getCreateTableSpecificationFor(mappingContext.getRequiredPersistentEntity(EntityWithComplexId.class)); + schemaFactory + .getCreateTableSpecificationFor(mappingContext.getRequiredPersistentEntity(EntityWithComplexId.class)); fail("Missing MappingException"); } catch (MappingException e) { assertThat(e).hasMessageContaining( @@ -606,7 +608,6 @@ private ColumnSpecification getColumn(String columnName, CreateTableSpecificatio String.format("Cannot find column '%s' amongst '%s'", columnName, specification.getColumns())); } - @Data @Table private static class Employee { @@ -620,7 +621,6 @@ private static class Employee { @CassandraType(type = Name.SET, typeArguments = Name.BIGINT) List enemies; } - @Data @Table private static class WithMappedTuple { @@ -633,11 +633,11 @@ private static class WithMappedTuple { private static class MappedTuple { @Element(0) MappedUdt mappedUdt; - @Element(1) @CassandraType(type = Name.UDT, userTypeName = "human_udt") UdtValue human; + @Element(1) + @CassandraType(type = Name.UDT, userTypeName = "human_udt") UdtValue human; @Element(2) String text; } - @Data @Table private static class WithUdtFields { @@ -648,7 +648,6 @@ private static class WithUdtFields { @CassandraType(type = Name.SET, typeArguments = Name.UDT, userTypeName = "peeps_udt") Set people; } - @Data @Table private static class WithMappedUdtFields { @@ -664,9 +663,6 @@ private static class WithMappedUdtFields { @org.springframework.data.cassandra.core.mapping.UserDefinedType private static class MappedUdt {} - @Data - @AllArgsConstructor - @NoArgsConstructor static class Human { String firstname; @@ -796,16 +792,15 @@ private static class UntypedTupleMapEntity { } @Table - @Data static class TypeWithEmbedded { @Id String id; @Embedded.Nullable EmbeddedTpe name; @Embedded.Nullable(prefix = "a") EmbeddedTpe alias; - @Indexed @Embedded.Nullable(prefix = "aego") EmbeddedTpe alterEgo; + @Indexed + @Embedded.Nullable(prefix = "aego") EmbeddedTpe alterEgo; } - @Data static class EmbeddedTpe { @Indexed String firstname; @@ -852,7 +847,6 @@ void createIndexSpecificationShouldConsiderEmbeddedType() { } @Table - @Data static class TypeWithStatic { @Id String id; @@ -860,7 +854,6 @@ static class TypeWithStatic { } @Table - @Data static class TypeWithStaticTuple { @Id String id; @@ -877,8 +870,7 @@ static class Address { @Test // GH-978 void createdTableSpecificationShouldConsiderStaticColumns() { - CassandraPersistentEntity persistentEntity = mappingContext - .getRequiredPersistentEntity(TypeWithStatic.class); + CassandraPersistentEntity persistentEntity = mappingContext.getRequiredPersistentEntity(TypeWithStatic.class); CreateTableSpecification tableSpecification = schemaFactory.getCreateTableSpecificationFor(persistentEntity); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/TimeEntity.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/TimeEntity.java index 49d2dda83..421c8654a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/TimeEntity.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/TimeEntity.java @@ -15,11 +15,6 @@ */ package org.springframework.data.cassandra.core.convert; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.data.cassandra.core.mapping.CassandraType; import org.springframework.data.cassandra.core.mapping.PrimaryKey; import org.springframework.data.cassandra.core.mapping.Table; @@ -28,11 +23,6 @@ * @author Mark Paluch */ @Table -@Data -@NoArgsConstructor -@RequiredArgsConstructor -public class TimeEntity { +public record TimeEntity(@PrimaryKey String id, @CassandraType(type = CassandraType.Name.TIME) long time) { - @PrimaryKey @NonNull private String id; - @CassandraType(type = CassandraType.Name.TIME) private long time; } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/UpdateMapperUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/UpdateMapperUnitTests.java index f9b371cd7..9e8887a5d 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/UpdateMapperUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/UpdateMapperUnitTests.java @@ -18,9 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; -import lombok.AllArgsConstructor; -import lombok.Data; - import java.time.LocalTime; import java.util.Arrays; import java.util.Collections; @@ -409,40 +406,98 @@ static class Person { } @Tuple - @AllArgsConstructor static class MappedTuple { @Element(0) String zip; + + public MappedTuple(String zip) { + this.zip = zip; + } } - @Data @UserDefinedType - @AllArgsConstructor static class Manufacturer { String name; + + public Manufacturer(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } } - @Data static class WithNullableEmbeddedType { @Id String id; @Embedded.Nullable EmbeddedWithSimpleTypes nested; + + public String getId() { + return this.id; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setId(String id) { + this.id = id; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } } - @Data static class WithPrefixedNullableEmbeddedType { @Id String id; // @Indexed -> index for all properties of nested @Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested; + + public String getId() { + return this.id; + } + + public EmbeddedWithSimpleTypes getNested() { + return this.nested; + } + + public void setId(String id) { + this.id = id; + } + + public void setNested(EmbeddedWithSimpleTypes nested) { + this.nested = nested; + } } - @Data static class EmbeddedWithSimpleTypes { @Indexed String firstname; Integer age; + + public @Indexed String getFirstname() { + return this.firstname; + } + + public Integer getAge() { + return this.age; + } + + public void setFirstname(@Indexed String firstname) { + this.firstname = firstname; + } + + public void setAge(Integer age) { + this.age = age; + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CassandraCompositePrimaryKeyUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CassandraCompositePrimaryKeyUnitTests.java index 4e2e2d034..66e81867e 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CassandraCompositePrimaryKeyUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CassandraCompositePrimaryKeyUnitTests.java @@ -17,8 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.EqualsAndHashCode; - import java.io.Serializable; import java.lang.reflect.Field; import java.util.Date; @@ -32,6 +30,7 @@ import org.springframework.data.cassandra.core.cql.keyspace.CreateTableSpecification; import org.springframework.data.mapping.model.Property; import org.springframework.data.util.TypeInformation; +import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; import com.datastax.oss.driver.api.core.type.DataTypes; @@ -66,8 +65,7 @@ void validateMappingInfo() { Field field = ReflectionUtils.findField(TypeWithCompositeKey.class, "id"); CassandraPersistentProperty property = new BasicCassandraPersistentProperty( - Property.of(TypeInformation.of(TypeWithCompositeKey.class), field), entity, - CassandraSimpleTypeHolder.HOLDER); + Property.of(TypeInformation.of(TypeWithCompositeKey.class), field), entity, CassandraSimpleTypeHolder.HOLDER); assertThat(property.isIdProperty()).isTrue(); assertThat(property.isCompositePrimaryKey()).isTrue(); @@ -89,7 +87,6 @@ void validateMappingInfo() { } @PrimaryKeyClass - @EqualsAndHashCode static class CompositeKey implements Serializable { private static final long serialVersionUID = 1L; @@ -97,6 +94,28 @@ static class CompositeKey implements Serializable { @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String z; @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.CLUSTERED) String a; + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + CompositeKey that = (CompositeKey) o; + + if (!ObjectUtils.nullSafeEquals(z, that.z)) { + return false; + } + return ObjectUtils.nullSafeEquals(a, that.a); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(z); + result = 31 * result + ObjectUtils.nullSafeHashCode(a); + return result; + } } @Table diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CassandraPersistentEntityOrderPropertiesUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CassandraPersistentEntityOrderPropertiesUnitTests.java index 9730cae99..da56b9032 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CassandraPersistentEntityOrderPropertiesUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CassandraPersistentEntityOrderPropertiesUnitTests.java @@ -26,7 +26,7 @@ import org.springframework.data.annotation.Id; import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.mapping.PropertyHandler; -import org.springframework.lang.Nullable; +import org.springframework.util.ObjectUtils; /** * Unit tests for {@link CassandraMappingContext}. @@ -101,42 +101,30 @@ private static class CompositePK implements Serializable { @PrimaryKeyColumn(ordinal = 1) private String key2; @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((key0 == null) ? 0 : key0.hashCode()); - result = prime * result + ((key1 == null) ? 0 : key1.hashCode()); - result = prime * result + ((key2 == null) ? 0 : key2.hashCode()); - return result; - } - - @Override - public boolean equals(@Nullable Object obj) { - if (this == obj) + public boolean equals(Object o) { + if (this == o) return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CompositePK other = (CompositePK) obj; - if (key0 == null) { - if (other.key0 != null) - return false; - } else if (!key0.equals(other.key0)) + if (o == null || getClass() != o.getClass()) return false; - if (key1 == null) { - if (other.key1 != null) - return false; - } else if (!key1.equals(other.key1)) + + CompositePK that = (CompositePK) o; + + if (!ObjectUtils.nullSafeEquals(key0, that.key0)) { return false; - if (key2 == null) { - if (other.key2 != null) - return false; - } else if (!key2.equals(other.key2)) + } + if (!ObjectUtils.nullSafeEquals(key1, that.key1)) { return false; - return true; + } + return ObjectUtils.nullSafeEquals(key2, that.key2); } + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(key0); + result = 31 * result + ObjectUtils.nullSafeHashCode(key1); + result = 31 * result + ObjectUtils.nullSafeHashCode(key2); + return result; + } } @Table diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CreateUserTypeIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CreateUserTypeIntegrationTests.java index b5bbd0280..15bea8ce7 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CreateUserTypeIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/CreateUserTypeIntegrationTests.java @@ -17,9 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Getter; - import java.util.Arrays; import java.util.List; @@ -67,27 +64,55 @@ void shouldCreateUserTypes() { } @Table - @Getter - @AllArgsConstructor private static class Car { @Id String id; Engine engine; + + public Car(String id, Engine engine) { + this.id = id; + this.engine = engine; + } + + public String getId() { + return this.id; + } + + public Engine getEngine() { + return this.engine; + } } @UserDefinedType - @Getter - @AllArgsConstructor private static class Engine { Manufacturer manufacturer; List alternative; + + public Engine(Manufacturer manufacturer, List alternative) { + this.manufacturer = manufacturer; + this.alternative = alternative; + } + + public Manufacturer getManufacturer() { + return this.manufacturer; + } + + public List getAlternative() { + return this.alternative; + } } @UserDefinedType - @Getter - @AllArgsConstructor private static class Manufacturer { String name; + + public Manufacturer(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/event/AuditingEntityCallbackUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/event/AuditingEntityCallbackUnitTests.java index a0a714754..c05454d8b 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/event/AuditingEntityCallbackUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/event/AuditingEntityCallbackUnitTests.java @@ -19,11 +19,6 @@ import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; -import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; -import lombok.Value; -import lombok.With; - import java.util.Collections; import java.util.Date; @@ -106,9 +101,9 @@ void hasExplicitOrder() { @Test // DATACASS-4 void propagatesChangedInstanceToEvent() { - ImmutableSample sample = new ImmutableSample(); + ImmutableSample sample = new ImmutableSample("a", null, null); - ImmutableSample newSample = new ImmutableSample(); + ImmutableSample newSample = new ImmutableSample("a", null, null); IsNewAwareAuditingHandler handler = mock(IsNewAwareAuditingHandler.class); doReturn(newSample).when(handler).markAudited(eq(sample)); @@ -125,14 +120,8 @@ private static class Sample { @LastModifiedDate Date modified; } - @Value - @With - @AllArgsConstructor - @NoArgsConstructor(force = true) - static class ImmutableSample { + record ImmutableSample( - @Id String id; - @CreatedDate Date created; - @LastModifiedDate Date modified; + @Id String id, @CreatedDate Date created, @LastModifiedDate Date modified) { } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/event/ReactiveAuditingEntityCallbackUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/event/ReactiveAuditingEntityCallbackUnitTests.java index 2ee78500e..76970467e 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/event/ReactiveAuditingEntityCallbackUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/event/ReactiveAuditingEntityCallbackUnitTests.java @@ -19,10 +19,6 @@ import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; -import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; -import lombok.Value; -import lombok.With; import reactor.core.publisher.Mono; import java.util.Collections; @@ -107,9 +103,9 @@ void hasExplicitOrder() { @Test // DATACASS-4, DATACASS-784 void propagatesChangedInstanceToEvent() { - ImmutableSample sample = new ImmutableSample(); + ImmutableSample sample = new ImmutableSample("a", null, null); - ImmutableSample newSample = new ImmutableSample(); + ImmutableSample newSample = new ImmutableSample("a", null, null); ReactiveIsNewAwareAuditingHandler handler = mock(ReactiveIsNewAwareAuditingHandler.class); doReturn(Mono.just(newSample)).when(handler).markAudited(eq(sample)); @@ -126,14 +122,6 @@ private static class Sample { @LastModifiedDate Date modified; } - @Value - @With - @AllArgsConstructor - @NoArgsConstructor(force = true) - static class ImmutableSample { - - @Id String id; - @CreatedDate Date created; - @LastModifiedDate Date modified; + record ImmutableSample(@Id String id, @CreatedDate Date created, @LastModifiedDate Date modified) { } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AddressType.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AddressType.java index 01fe9b38c..543d38161 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AddressType.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AddressType.java @@ -15,21 +15,60 @@ */ package org.springframework.data.cassandra.domain; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import org.springframework.data.cassandra.core.mapping.UserDefinedType; +import org.springframework.util.ObjectUtils; /** * @author Mark Paluch */ @UserDefinedType("address") -@Data -@AllArgsConstructor -@NoArgsConstructor public class AddressType { String city; String country; + + public AddressType(String city, String country) { + this.city = city; + this.country = country; + } + + public AddressType() {} + + public String getCity() { + return this.city; + } + + public String getCountry() { + return this.country; + } + + public void setCity(String city) { + this.city = city; + } + + public void setCountry(String country) { + this.country = country; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + AddressType that = (AddressType) o; + + if (!ObjectUtils.nullSafeEquals(city, that.city)) { + return false; + } + return ObjectUtils.nullSafeEquals(country, that.country); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(city); + result = 31 * result + ObjectUtils.nullSafeHashCode(country); + return result; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AllPossibleTypes.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AllPossibleTypes.java index 28ad022bb..e51af3ba1 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AllPossibleTypes.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/AllPossibleTypes.java @@ -17,15 +17,15 @@ import static org.springframework.data.cassandra.core.mapping.CassandraType.*; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.math.BigDecimal; import java.math.BigInteger; import java.net.InetAddress; import java.nio.ByteBuffer; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; import java.util.Date; import java.util.List; import java.util.Map; @@ -36,6 +36,7 @@ import org.springframework.data.cassandra.core.mapping.CassandraType; import org.springframework.data.cassandra.core.mapping.PrimaryKey; import org.springframework.data.cassandra.core.mapping.Table; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.data.TupleValue; @@ -43,12 +44,9 @@ * @author Mark Paluch */ @Table -@Data -@NoArgsConstructor -@RequiredArgsConstructor public class AllPossibleTypes { - @PrimaryKey @NonNull String id; + @PrimaryKey String id; InetAddress inet; @@ -101,4 +99,426 @@ public class AllPossibleTypes { java.time.LocalDateTime localDateTime; java.time.ZoneId zoneId; + public AllPossibleTypes(String id) { + this.id = id; + } + + public AllPossibleTypes() {} + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public InetAddress getInet() { + return inet; + } + + public void setInet(InetAddress inet) { + this.inet = inet; + } + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public Number getJustNumber() { + return justNumber; + } + + public void setJustNumber(Number justNumber) { + this.justNumber = justNumber; + } + + public Byte getBoxedByte() { + return boxedByte; + } + + public void setBoxedByte(Byte boxedByte) { + this.boxedByte = boxedByte; + } + + public byte getPrimitiveByte() { + return primitiveByte; + } + + public void setPrimitiveByte(byte primitiveByte) { + this.primitiveByte = primitiveByte; + } + + public Short getBoxedShort() { + return boxedShort; + } + + public void setBoxedShort(Short boxedShort) { + this.boxedShort = boxedShort; + } + + public short getPrimitiveShort() { + return primitiveShort; + } + + public void setPrimitiveShort(short primitiveShort) { + this.primitiveShort = primitiveShort; + } + + public Long getBoxedLong() { + return boxedLong; + } + + public void setBoxedLong(Long boxedLong) { + this.boxedLong = boxedLong; + } + + public long getPrimitiveLong() { + return primitiveLong; + } + + public void setPrimitiveLong(long primitiveLong) { + this.primitiveLong = primitiveLong; + } + + public Integer getBoxedInteger() { + return boxedInteger; + } + + public void setBoxedInteger(Integer boxedInteger) { + this.boxedInteger = boxedInteger; + } + + public int getPrimitiveInteger() { + return primitiveInteger; + } + + public void setPrimitiveInteger(int primitiveInteger) { + this.primitiveInteger = primitiveInteger; + } + + public Float getBoxedFloat() { + return boxedFloat; + } + + public void setBoxedFloat(Float boxedFloat) { + this.boxedFloat = boxedFloat; + } + + public float getPrimitiveFloat() { + return primitiveFloat; + } + + public void setPrimitiveFloat(float primitiveFloat) { + this.primitiveFloat = primitiveFloat; + } + + public Double getBoxedDouble() { + return boxedDouble; + } + + public void setBoxedDouble(Double boxedDouble) { + this.boxedDouble = boxedDouble; + } + + public double getPrimitiveDouble() { + return primitiveDouble; + } + + public void setPrimitiveDouble(double primitiveDouble) { + this.primitiveDouble = primitiveDouble; + } + + public Boolean getBoxedBoolean() { + return boxedBoolean; + } + + public void setBoxedBoolean(Boolean boxedBoolean) { + this.boxedBoolean = boxedBoolean; + } + + public boolean isPrimitiveBoolean() { + return primitiveBoolean; + } + + public void setPrimitiveBoolean(boolean primitiveBoolean) { + this.primitiveBoolean = primitiveBoolean; + } + + public Instant getInstant() { + return instant; + } + + public void setInstant(Instant instant) { + this.instant = instant; + } + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public LocalTime getTime() { + return time; + } + + public void setTime(LocalTime time) { + this.time = time; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public BigDecimal getBigDecimal() { + return bigDecimal; + } + + public void setBigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + } + + public BigInteger getBigInteger() { + return bigInteger; + } + + public void setBigInteger(BigInteger bigInteger) { + this.bigInteger = bigInteger; + } + + public ByteBuffer getBlob() { + return blob; + } + + public void setBlob(ByteBuffer blob) { + this.blob = blob; + } + + public Set getSetOfString() { + return setOfString; + } + + public void setSetOfString(Set setOfString) { + this.setOfString = setOfString; + } + + public List getListOfString() { + return listOfString; + } + + public void setListOfString(List listOfString) { + this.listOfString = listOfString; + } + + public Map getMapOfString() { + return mapOfString; + } + + public void setMapOfString(Map mapOfString) { + this.mapOfString = mapOfString; + } + + public Condition getAnEnum() { + return anEnum; + } + + public void setAnEnum(Condition anEnum) { + this.anEnum = anEnum; + } + + public Set getSetOfEnum() { + return setOfEnum; + } + + public void setSetOfEnum(Set setOfEnum) { + this.setOfEnum = setOfEnum; + } + + public List getListOfEnum() { + return listOfEnum; + } + + public void setListOfEnum(List listOfEnum) { + this.listOfEnum = listOfEnum; + } + + public TupleValue getTupleValue() { + return tupleValue; + } + + public void setTupleValue(TupleValue tupleValue) { + this.tupleValue = tupleValue; + } + + public LocalDateTime getLocalDateTime() { + return localDateTime; + } + + public void setLocalDateTime(LocalDateTime localDateTime) { + this.localDateTime = localDateTime; + } + + public ZoneId getZoneId() { + return zoneId; + } + + public void setZoneId(ZoneId zoneId) { + this.zoneId = zoneId; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + AllPossibleTypes that = (AllPossibleTypes) o; + + if (primitiveByte != that.primitiveByte) + return false; + if (primitiveShort != that.primitiveShort) + return false; + if (primitiveLong != that.primitiveLong) + return false; + if (primitiveInteger != that.primitiveInteger) + return false; + if (primitiveFloat != that.primitiveFloat) + return false; + if (primitiveDouble != that.primitiveDouble) + return false; + if (primitiveBoolean != that.primitiveBoolean) + return false; + if (!ObjectUtils.nullSafeEquals(id, that.id)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(inet, that.inet)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(uuid, that.uuid)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(justNumber, that.justNumber)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(boxedByte, that.boxedByte)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(boxedShort, that.boxedShort)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(boxedLong, that.boxedLong)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(boxedInteger, that.boxedInteger)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(boxedFloat, that.boxedFloat)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(boxedDouble, that.boxedDouble)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(boxedBoolean, that.boxedBoolean)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(instant, that.instant)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(date, that.date)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(time, that.time)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(timestamp, that.timestamp)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(bigDecimal, that.bigDecimal)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(bigInteger, that.bigInteger)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(blob, that.blob)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(setOfString, that.setOfString)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(listOfString, that.listOfString)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(mapOfString, that.mapOfString)) { + return false; + } + if (anEnum != that.anEnum) + return false; + if (!ObjectUtils.nullSafeEquals(setOfEnum, that.setOfEnum)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(listOfEnum, that.listOfEnum)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(tupleValue, that.tupleValue)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(localDateTime, that.localDateTime)) { + return false; + } + return ObjectUtils.nullSafeEquals(zoneId, that.zoneId); + } + + @Override + public int hashCode() { + int result; + long temp; + result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(inet); + result = 31 * result + ObjectUtils.nullSafeHashCode(uuid); + result = 31 * result + ObjectUtils.nullSafeHashCode(justNumber); + result = 31 * result + ObjectUtils.nullSafeHashCode(boxedByte); + result = 31 * result + (int) primitiveByte; + result = 31 * result + ObjectUtils.nullSafeHashCode(boxedShort); + result = 31 * result + (int) primitiveShort; + result = 31 * result + ObjectUtils.nullSafeHashCode(boxedLong); + result = 31 * result + (int) (primitiveLong ^ (primitiveLong >>> 32)); + result = 31 * result + ObjectUtils.nullSafeHashCode(boxedInteger); + result = 31 * result + primitiveInteger; + result = 31 * result + ObjectUtils.nullSafeHashCode(boxedFloat); + result = 31 * result + (primitiveFloat != +0.0f ? Float.floatToIntBits(primitiveFloat) : 0); + result = 31 * result + ObjectUtils.nullSafeHashCode(boxedDouble); + temp = Double.doubleToLongBits(primitiveDouble); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + result = 31 * result + ObjectUtils.nullSafeHashCode(boxedBoolean); + result = 31 * result + (primitiveBoolean ? 1 : 0); + result = 31 * result + ObjectUtils.nullSafeHashCode(instant); + result = 31 * result + ObjectUtils.nullSafeHashCode(date); + result = 31 * result + ObjectUtils.nullSafeHashCode(time); + result = 31 * result + ObjectUtils.nullSafeHashCode(timestamp); + result = 31 * result + ObjectUtils.nullSafeHashCode(bigDecimal); + result = 31 * result + ObjectUtils.nullSafeHashCode(bigInteger); + result = 31 * result + ObjectUtils.nullSafeHashCode(blob); + result = 31 * result + ObjectUtils.nullSafeHashCode(setOfString); + result = 31 * result + ObjectUtils.nullSafeHashCode(listOfString); + result = 31 * result + ObjectUtils.nullSafeHashCode(mapOfString); + result = 31 * result + ObjectUtils.nullSafeHashCode(anEnum); + result = 31 * result + ObjectUtils.nullSafeHashCode(setOfEnum); + result = 31 * result + ObjectUtils.nullSafeHashCode(listOfEnum); + result = 31 * result + ObjectUtils.nullSafeHashCode(tupleValue); + result = 31 * result + ObjectUtils.nullSafeHashCode(localDateTime); + result = 31 * result + ObjectUtils.nullSafeHashCode(zoneId); + return result; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/BookReference.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/BookReference.java index a49d665c5..8ef15c3e3 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/BookReference.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/BookReference.java @@ -15,7 +15,6 @@ */ package org.springframework.data.cassandra.domain; -import lombok.Data; import java.util.List; import java.util.Map; @@ -31,7 +30,6 @@ * @author Mark Paluch */ @Table("bookReference") -@Data public class BookReference { @PrimaryKey private String isbn; @@ -40,4 +38,44 @@ public class BookReference { private Set references; private List bookmarks; private Map credits; + + public String getIsbn() { + return this.isbn; + } + + public String getTitle() { + return this.title; + } + + public Set getReferences() { + return this.references; + } + + public List getBookmarks() { + return this.bookmarks; + } + + public Map getCredits() { + return this.credits; + } + + public void setIsbn(String isbn) { + this.isbn = isbn; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setReferences(Set references) { + this.references = references; + } + + public void setBookmarks(List bookmarks) { + this.bookmarks = bookmarks; + } + + public void setCredits(Map credits) { + this.credits = credits; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/CompositeKey.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/CompositeKey.java index d057a97df..3a43e90da 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/CompositeKey.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/CompositeKey.java @@ -15,10 +15,6 @@ */ package org.springframework.data.cassandra.domain; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.Serializable; import org.springframework.data.cassandra.core.cql.PrimaryKeyType; @@ -29,11 +25,31 @@ * @author Mark Paluch */ @PrimaryKeyClass -@Data -@AllArgsConstructor -@NoArgsConstructor public class CompositeKey implements Serializable { @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 1, name = "first_name") private String firstname; @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 2) private String lastname; + + public CompositeKey(String firstname, String lastname) { + this.firstname = firstname; + this.lastname = lastname; + } + + public CompositeKey() {} + + public String getFirstname() { + return this.firstname; + } + + public String getLastname() { + return this.lastname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/FlatGroup.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/FlatGroup.java index 923b00314..596ebfcdb 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/FlatGroup.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/FlatGroup.java @@ -15,7 +15,6 @@ */ package org.springframework.data.cassandra.domain; -import lombok.Data; import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; @@ -27,7 +26,6 @@ * "https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling">https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling */ @Table -@Data public class FlatGroup { @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) private String groupname; @@ -42,4 +40,44 @@ public FlatGroup(String groupname, String hashPrefix, String username) { this.hashPrefix = hashPrefix; this.username = username; } + + public String getGroupname() { + return this.groupname; + } + + public String getHashPrefix() { + return this.hashPrefix; + } + + public String getUsername() { + return this.username; + } + + public String getEmail() { + return this.email; + } + + public int getAge() { + return this.age; + } + + public void setGroupname(String groupname) { + this.groupname = groupname; + } + + public void setHashPrefix(String hashPrefix) { + this.hashPrefix = hashPrefix; + } + + public void setUsername(String username) { + this.username = username; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setAge(int age) { + this.age = age; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Group.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Group.java index 380977abc..6e9fb75bf 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Group.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Group.java @@ -15,11 +15,10 @@ */ package org.springframework.data.cassandra.domain; -import lombok.Data; -import lombok.NoArgsConstructor; import org.springframework.data.cassandra.core.mapping.PrimaryKey; import org.springframework.data.cassandra.core.mapping.Table; +import org.springframework.util.ObjectUtils; /** * @author Mark Paluch @@ -27,8 +26,6 @@ * "https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling">https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling */ @Table -@Data -@NoArgsConstructor public class Group { @PrimaryKey private GroupKey id; @@ -39,4 +36,55 @@ public class Group { public Group(GroupKey id) { this.id = id; } + + public Group() {} + + public GroupKey getId() { + return this.id; + } + + public String getEmail() { + return this.email; + } + + public int getAge() { + return this.age; + } + + public void setId(GroupKey id) { + this.id = id; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Group group = (Group) o; + + if (age != group.age) + return false; + if (!ObjectUtils.nullSafeEquals(id, group.id)) { + return false; + } + return ObjectUtils.nullSafeEquals(email, group.email); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(email); + result = 31 * result + age; + return result; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/GroupKey.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/GroupKey.java index 44dc1bf9c..852827249 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/GroupKey.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/GroupKey.java @@ -15,15 +15,12 @@ */ package org.springframework.data.cassandra.domain; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.Serializable; import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; +import org.springframework.util.ObjectUtils; /** * @author Mark Paluch @@ -31,12 +28,67 @@ * "https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling">https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling */ @PrimaryKeyClass -@Data -@AllArgsConstructor -@NoArgsConstructor public class GroupKey implements Serializable { @PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) private String groupname; @PrimaryKeyColumn(name = "hash_prefix", ordinal = 2, type = PrimaryKeyType.PARTITIONED) private String hashPrefix; @PrimaryKeyColumn(ordinal = 3, type = PrimaryKeyType.CLUSTERED) private String username; + + public GroupKey(String groupname, String hashPrefix, String username) { + this.groupname = groupname; + this.hashPrefix = hashPrefix; + this.username = username; + } + + public GroupKey() {} + + public String getGroupname() { + return this.groupname; + } + + public String getHashPrefix() { + return this.hashPrefix; + } + + public String getUsername() { + return this.username; + } + + public void setGroupname(String groupname) { + this.groupname = groupname; + } + + public void setHashPrefix(String hashPrefix) { + this.hashPrefix = hashPrefix; + } + + public void setUsername(String username) { + this.username = username; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + GroupKey groupKey = (GroupKey) o; + + if (!ObjectUtils.nullSafeEquals(groupname, groupKey.groupname)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(hashPrefix, groupKey.hashPrefix)) { + return false; + } + return ObjectUtils.nullSafeEquals(username, groupKey.username); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(groupname); + result = 31 * result + ObjectUtils.nullSafeHashCode(hashPrefix); + result = 31 * result + ObjectUtils.nullSafeHashCode(username); + return result; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Person.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Person.java index 7fe9aa6aa..cab6c4ae7 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Person.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/Person.java @@ -15,10 +15,6 @@ */ package org.springframework.data.cassandra.domain; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.time.LocalDate; import java.time.ZoneId; import java.util.Date; @@ -27,14 +23,12 @@ import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.core.mapping.Table; +import org.springframework.util.ObjectUtils; /** * @author Mark Paluch */ @Table -@Data -@AllArgsConstructor -@NoArgsConstructor public class Person { @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0) private String lastname; @@ -57,4 +51,152 @@ public Person(String firstname, String lastname) { this.firstname = firstname; this.lastname = lastname; } + + public Person(String lastname, String firstname, String nickname, Date birthDate, int numberOfChildren, boolean cool, + LocalDate createdDate, ZoneId zoneId, AddressType mainAddress, List alternativeAddresses) { + this.lastname = lastname; + this.firstname = firstname; + this.nickname = nickname; + this.birthDate = birthDate; + this.numberOfChildren = numberOfChildren; + this.cool = cool; + this.createdDate = createdDate; + this.zoneId = zoneId; + this.mainAddress = mainAddress; + this.alternativeAddresses = alternativeAddresses; + } + + public Person() {} + + public String getLastname() { + return this.lastname; + } + + public String getFirstname() { + return this.firstname; + } + + public String getNickname() { + return this.nickname; + } + + public Date getBirthDate() { + return this.birthDate; + } + + public int getNumberOfChildren() { + return this.numberOfChildren; + } + + public boolean isCool() { + return this.cool; + } + + public LocalDate getCreatedDate() { + return this.createdDate; + } + + public ZoneId getZoneId() { + return this.zoneId; + } + + public AddressType getMainAddress() { + return this.mainAddress; + } + + public List getAlternativeAddresses() { + return this.alternativeAddresses; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setNickname(String nickname) { + this.nickname = nickname; + } + + public void setBirthDate(Date birthDate) { + this.birthDate = birthDate; + } + + public void setNumberOfChildren(int numberOfChildren) { + this.numberOfChildren = numberOfChildren; + } + + public void setCool(boolean cool) { + this.cool = cool; + } + + public void setCreatedDate(LocalDate createdDate) { + this.createdDate = createdDate; + } + + public void setZoneId(ZoneId zoneId) { + this.zoneId = zoneId; + } + + public void setMainAddress(AddressType mainAddress) { + this.mainAddress = mainAddress; + } + + public void setAlternativeAddresses(List alternativeAddresses) { + this.alternativeAddresses = alternativeAddresses; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Person person = (Person) o; + + if (numberOfChildren != person.numberOfChildren) + return false; + if (cool != person.cool) + return false; + if (!ObjectUtils.nullSafeEquals(lastname, person.lastname)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(nickname, person.nickname)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(birthDate, person.birthDate)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(createdDate, person.createdDate)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(zoneId, person.zoneId)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(mainAddress, person.mainAddress)) { + return false; + } + return ObjectUtils.nullSafeEquals(alternativeAddresses, person.alternativeAddresses); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(lastname); + result = 31 * result + ObjectUtils.nullSafeHashCode(firstname); + result = 31 * result + ObjectUtils.nullSafeHashCode(nickname); + result = 31 * result + ObjectUtils.nullSafeHashCode(birthDate); + result = 31 * result + numberOfChildren; + result = 31 * result + (cool ? 1 : 0); + result = 31 * result + ObjectUtils.nullSafeHashCode(createdDate); + result = 31 * result + ObjectUtils.nullSafeHashCode(zoneId); + result = 31 * result + ObjectUtils.nullSafeHashCode(mainAddress); + result = 31 * result + ObjectUtils.nullSafeHashCode(alternativeAddresses); + return result; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithCompositeKey.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithCompositeKey.java index eef780110..d346632c5 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithCompositeKey.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithCompositeKey.java @@ -15,8 +15,6 @@ */ package org.springframework.data.cassandra.domain; -import lombok.Data; - import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.core.mapping.Table; @@ -25,9 +23,24 @@ * @author Mark Paluch */ @Table -@Data public class TypeWithCompositeKey { @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 1) private String firstname; @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 2) private String lastname; + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithKeyClass.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithKeyClass.java index 23dfa0da5..a064bb7db 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithKeyClass.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithKeyClass.java @@ -15,7 +15,6 @@ */ package org.springframework.data.cassandra.domain; -import lombok.Data; import org.springframework.data.cassandra.core.mapping.PrimaryKey; import org.springframework.data.cassandra.core.mapping.Table; @@ -24,8 +23,15 @@ * @author Mark Paluch */ @Table -@Data public class TypeWithKeyClass { @PrimaryKey CompositeKey key; + + public CompositeKey getKey() { + return this.key; + } + + public void setKey(CompositeKey key) { + this.key = key; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithMapId.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithMapId.java index 1e178dc79..3779c91b7 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithMapId.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/TypeWithMapId.java @@ -15,8 +15,6 @@ */ package org.springframework.data.cassandra.domain; -import lombok.Data; - import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.cassandra.core.mapping.BasicMapId; import org.springframework.data.cassandra.core.mapping.MapId; @@ -28,12 +26,27 @@ * @author Mark Paluch */ @Table -@Data public class TypeWithMapId implements MapIdentifiable { @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 1) private String firstname; @PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 2) private String lastname; + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + @Override public MapId getMapId() { return BasicMapId.id("firstname", firstname).with("lastname", lastname); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/User.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/User.java index 025db2500..e616089f7 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/User.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/User.java @@ -15,9 +15,7 @@ */ package org.springframework.data.cassandra.domain; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; +import java.util.Objects; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.PersistenceConstructor; @@ -28,9 +26,6 @@ * @author Mark Paluch */ @Table("users") -@Data -@NoArgsConstructor -@EqualsAndHashCode(of = "id") public class User { /* @@ -44,6 +39,8 @@ public class User { private String firstname; private String lastname; + public User() {} + @PersistenceConstructor public User(String id, String firstname, String lastname) { @@ -51,4 +48,45 @@ public User(String id, String firstname, String lastname) { this.firstname = firstname; this.lastname = lastname; } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + User user = (User) o; + + return Objects.equals(id, user.id); + } + + @Override + public int hashCode() { + return id != null ? id.hashCode() : 0; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/UserToken.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/UserToken.java index 55e68ba82..a73adee72 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/UserToken.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/UserToken.java @@ -15,20 +15,18 @@ */ package org.springframework.data.cassandra.domain; -import lombok.Data; - import java.util.UUID; import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.cassandra.core.mapping.Column; import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.core.mapping.Table; +import org.springframework.util.ObjectUtils; /** * @author Mark Paluch */ @Table("user_tokens") -@Data public class UserToken { @PrimaryKeyColumn(name = "user_id", type = PrimaryKeyType.PARTITIONED, ordinal = 0) private UUID userId; @@ -37,4 +35,65 @@ public class UserToken { @Column("user_comment") String userComment; String adminComment; + public UUID getUserId() { + return userId; + } + + public void setUserId(UUID userId) { + this.userId = userId; + } + + public UUID getToken() { + return token; + } + + public void setToken(UUID token) { + this.token = token; + } + + public String getUserComment() { + return userComment; + } + + public void setUserComment(String userComment) { + this.userComment = userComment; + } + + public String getAdminComment() { + return adminComment; + } + + public void setAdminComment(String adminComment) { + this.adminComment = adminComment; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + UserToken userToken = (UserToken) o; + + if (!ObjectUtils.nullSafeEquals(userId, userToken.userId)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(token, userToken.token)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(userComment, userToken.userComment)) { + return false; + } + return ObjectUtils.nullSafeEquals(adminComment, userToken.adminComment); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(userId); + result = 31 * result + ObjectUtils.nullSafeHashCode(token); + result = 31 * result + ObjectUtils.nullSafeHashCode(userComment); + result = 31 * result + ObjectUtils.nullSafeHashCode(adminComment); + return result; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/VersionedUser.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/VersionedUser.java index fe5185bf0..b62da9b4a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/VersionedUser.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/domain/VersionedUser.java @@ -15,22 +15,16 @@ */ package org.springframework.data.cassandra.domain; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - import org.springframework.data.annotation.Id; import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.data.annotation.Version; import org.springframework.data.cassandra.core.mapping.Table; +import org.springframework.util.ObjectUtils; /** * @author Mark Paluch */ @Table("vusers") -@Data -@NoArgsConstructor -@EqualsAndHashCode(of = "id") public class VersionedUser { /* @@ -53,4 +47,68 @@ public VersionedUser(String id, String firstname, String lastname) { this.firstname = firstname; this.lastname = lastname; } + + public VersionedUser() {} + + public String getId() { + return this.id; + } + + public Long getVersion() { + return this.version; + } + + public String getFirstname() { + return this.firstname; + } + + public String getLastname() { + return this.lastname; + } + + public void setId(String id) { + this.id = id; + } + + public void setVersion(Long version) { + this.version = version; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + VersionedUser that = (VersionedUser) o; + + if (!ObjectUtils.nullSafeEquals(id, that.id)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(version, that.version)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(firstname, that.firstname)) { + return false; + } + return ObjectUtils.nullSafeEquals(lastname, that.lastname); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(version); + result = 31 * result + ObjectUtils.nullSafeHashCode(firstname); + result = 31 * result + ObjectUtils.nullSafeHashCode(lastname); + return result; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/BigIntParamIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/BigIntParamIntegrationTests.java index 7a0bd41af..e7d3c8aff 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/BigIntParamIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/BigIntParamIntegrationTests.java @@ -18,10 +18,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.math.BigInteger; import java.util.Collections; import java.util.Set; @@ -81,12 +77,23 @@ void testQueryWithReference() { * @author Pete Cable */ @Table - @Data - @AllArgsConstructor - @NoArgsConstructor static class BigThing { @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private BigInteger number; + + public BigThing(BigInteger number) { + this.number = number; + } + + public BigThing() {} + + public BigInteger getNumber() { + return this.number; + } + + public void setNumber(BigInteger number) { + this.number = number; + } } /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/DateKeyIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/DateKeyIntegrationTests.java index ac6347fff..e4520fb7b 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/DateKeyIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/DateKeyIntegrationTests.java @@ -17,10 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.Collections; import java.util.Date; import java.util.Set; @@ -80,12 +76,23 @@ void testQueryWithDate() { * @author Matthew T. Adams */ @Table - @Data - @AllArgsConstructor - @NoArgsConstructor static class DateThing { @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private Date date; + + public DateThing(Date date) { + this.date = date; + } + + public DateThing() {} + + public Date getDate() { + return this.date; + } + + public void setDate(Date date) { + this.date = date; + } } /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/IntParamIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/IntParamIntegrationTests.java index 509c74e88..a445f0104 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/IntParamIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/IntParamIntegrationTests.java @@ -17,10 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.Collections; import java.util.Set; @@ -78,12 +74,23 @@ void testQueryWithIntPrimitiveAndReference() { } @Table - @Data - @AllArgsConstructor - @NoArgsConstructor static class IntThing { @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private int number; + + public IntThing(int number) { + this.number = number; + } + + public IntThing() {} + + public int getNumber() { + return this.number; + } + + public void setNumber(int number) { + this.number = number; + } } interface IntThingRepo extends MapIdCassandraRepository { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/QueryDerivationIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/QueryDerivationIntegrationTests.java index d1c0c8973..a7c0c9250 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/QueryDerivationIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/QueryDerivationIntegrationTests.java @@ -18,8 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.junit.Assume.*; -import lombok.Data; - import java.time.LocalDate; import java.util.ArrayList; import java.util.Arrays; @@ -60,6 +58,7 @@ import org.springframework.data.util.Version; import org.springframework.lang.Nullable; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import org.springframework.util.ObjectUtils; import com.datastax.oss.driver.api.core.CqlSession; @@ -469,17 +468,99 @@ static interface EmbeddedPersonRepository extends CassandraRepository getAddresses() { + return this.addresses; + } + + public Phone getMainPhone() { + return this.mainPhone; + } + + public List getAlternativePhones() { + return this.alternativePhones; + } + + public void setId(String id) { + this.id = id; + } + + public void setAddress(Address address) { + this.address = address; + } + + public void setAddresses(List
addresses) { + this.addresses = addresses; + } + + public void setMainPhone(Phone mainPhone) { + this.mainPhone = mainPhone; + } + + public void setAlternativePhones(List alternativePhones) { + this.alternativePhones = alternativePhones; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Contact contact = (Contact) o; + + if (!ObjectUtils.nullSafeEquals(id, contact.id)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(address, contact.address)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(addresses, contact.addresses)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(mainPhone, contact.mainPhone)) { + return false; + } + return ObjectUtils.nullSafeEquals(alternativePhones, contact.alternativePhones); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(id); + result = 31 * result + ObjectUtils.nullSafeHashCode(address); + result = 31 * result + ObjectUtils.nullSafeHashCode(addresses); + result = 31 * result + ObjectUtils.nullSafeHashCode(mainPhone); + result = 31 * result + ObjectUtils.nullSafeHashCode(alternativePhones); + return result; + } + } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/Phone.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/Phone.java index 671bc45a9..bf105137b 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/Phone.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/conversion/Phone.java @@ -15,13 +15,37 @@ */ package org.springframework.data.cassandra.repository.conversion; -import lombok.Data; +import org.springframework.util.ObjectUtils; /** * @author Mark Paluch */ -@Data class Phone { String number; + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Phone phone = (Phone) o; + + return ObjectUtils.nullSafeEquals(number, phone.number); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(number); + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/forcequote/compositeprimarykey/entity/CorrelationEntity.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/forcequote/compositeprimarykey/entity/CorrelationEntity.java index 8d2c640e6..19681557e 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/forcequote/compositeprimarykey/entity/CorrelationEntity.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/forcequote/compositeprimarykey/entity/CorrelationEntity.java @@ -25,7 +25,7 @@ import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.core.mapping.Table; -import org.springframework.lang.Nullable; +import org.springframework.util.ObjectUtils; /** * @author Matthew T. Adams @@ -119,32 +119,36 @@ public void setCorrelatedValue(String correlatedValue) { } @Override - public boolean equals(@Nullable Object o) { + public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof IdentityEntity)) + if (o == null || getClass() != o.getClass()) return false; IdentityEntity that = (IdentityEntity) o; - if (correlatedType != null ? !correlatedType.equals(that.correlatedType) : that.correlatedType != null) + if (!ObjectUtils.nullSafeEquals(type, that.type)) { return false; - if (correlatedValue != null ? !correlatedValue.equals(that.correlatedValue) : that.correlatedValue != null) + } + if (!ObjectUtils.nullSafeEquals(value, that.value)) { return false; - if (ts != null ? !ts.equals(that.ts) : that.ts != null) + } + if (!ObjectUtils.nullSafeEquals(correlatedType, that.correlatedType)) { return false; - if (!type.equals(that.type)) + } + if (!ObjectUtils.nullSafeEquals(ts, that.ts)) { return false; - return value.equals(that.value); + } + return ObjectUtils.nullSafeEquals(correlatedValue, that.correlatedValue); } @Override public int hashCode() { - int result = type.hashCode(); - result = 31 * result + value.hashCode(); - result = 31 * result + (correlatedType != null ? correlatedType.hashCode() : 0); - result = 31 * result + (ts != null ? ts.hashCode() : 0); - result = 31 * result + (correlatedValue != null ? correlatedValue.hashCode() : 0); + int result = ObjectUtils.nullSafeHashCode(type); + result = 31 * result + ObjectUtils.nullSafeHashCode(value); + result = 31 * result + ObjectUtils.nullSafeHashCode(correlatedType); + result = 31 * result + ObjectUtils.nullSafeHashCode(ts); + result = 31 * result + ObjectUtils.nullSafeHashCode(correlatedValue); return result; } } @@ -183,23 +187,24 @@ public void setExtra(Map extra) { } @Override - public boolean equals(@Nullable Object o) { + public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof CorrelationEntity)) + if (o == null || getClass() != o.getClass()) return false; CorrelationEntity that = (CorrelationEntity) o; - if (extra != null ? !extra.equals(that.extra) : that.extra != null) + if (!ObjectUtils.nullSafeEquals(identityEntity, that.identityEntity)) { return false; - return identityEntity.equals(that.identityEntity); + } + return ObjectUtils.nullSafeEquals(extra, that.extra); } @Override public int hashCode() { - int result = identityEntity.hashCode(); - result = 31 * result + (extra != null ? extra.hashCode() : 0); + int result = ObjectUtils.nullSafeHashCode(identityEntity); + result = 31 * result + ObjectUtils.nullSafeHashCode(extra); return result; } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryQueryMethodParameterTypesIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryQueryMethodParameterTypesIntegrationTests.java index aba86aa3a..03818b9a4 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryQueryMethodParameterTypesIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/isolated/RepositoryQueryMethodParameterTypesIntegrationTests.java @@ -57,9 +57,7 @@ * @author Mark Paluch */ @SpringJUnitConfig -@SuppressWarnings("Since15") -class RepositoryQueryMethodParameterTypesIntegrationTests - extends AbstractSpringDataEmbeddedCassandraIntegrationTest { +class RepositoryQueryMethodParameterTypesIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { @Configuration @EnableCassandraRepositories(basePackageClasses = RepositoryQueryMethodParameterTypesIntegrationTests.class, diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/mapid/SinglePrimaryKeyColumn.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/mapid/SinglePrimaryKeyColumn.java index 3b2877c64..9810d4541 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/mapid/SinglePrimaryKeyColumn.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/mapid/SinglePrimaryKeyColumn.java @@ -15,18 +15,16 @@ */ package org.springframework.data.cassandra.repository.mapid; -import lombok.EqualsAndHashCode; - import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.cassandra.core.mapping.Column; import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.core.mapping.Table; +import org.springframework.util.ObjectUtils; /** * @author Matthew T. Adams */ @Table -@EqualsAndHashCode public class SinglePrimaryKeyColumn { @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key; @@ -52,4 +50,26 @@ public String getValue() { public void setValue(String value) { this.value = value; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + SinglePrimaryKeyColumn that = (SinglePrimaryKeyColumn) o; + + if (!ObjectUtils.nullSafeEquals(key, that.key)) { + return false; + } + return ObjectUtils.nullSafeEquals(value, that.value); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(key); + result = 31 * result + ObjectUtils.nullSafeHashCode(value); + return result; + } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryUnitTests.java index d402a02c0..fb6f2beed 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepositoryUnitTests.java @@ -17,8 +17,6 @@ import static org.mockito.Mockito.*; -import lombok.Data; - import java.io.Serializable; import org.junit.jupiter.api.BeforeEach; @@ -79,7 +77,7 @@ void saveShouldInsertNewPrimaryKeyOnlyEntity() { repository = new SimpleCassandraRepository(new MappingCassandraEntityInformation(entity, converter), cassandraOperations); - SimplePerson person = new SimplePerson(); + SimplePerson person = new SimplePerson(null); when(cassandraOperations.insert(eq(person), any())).thenReturn(writeResult); when(writeResult.getEntity()).thenReturn(person); @@ -196,16 +194,29 @@ void shouldSelectWithPaging() { SimplePerson.class); } - @Data - static class SimplePerson { + record SimplePerson(@Id String id) { - @Id String id; } - @Data static class VersionedPerson { @Id String id; @Version long version; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public long getVersion() { + return version; + } + + public void setVersion(long version) { + this.version = version; + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleReactiveCassandraRepositoryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleReactiveCassandraRepositoryUnitTests.java index d3c352f35..cfd164a07 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleReactiveCassandraRepositoryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/support/SimpleReactiveCassandraRepositoryUnitTests.java @@ -17,7 +17,6 @@ import static org.mockito.Mockito.*; -import lombok.Data; import reactor.core.publisher.Mono; import java.io.Serializable; @@ -100,10 +99,25 @@ void shouldUpdateExistingVersionedEntity() { verify(cassandraOperations).update(versionedPerson); } - @Data static class VersionedPerson { @Id String id; @Version long version; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public long getVersion() { + return version; + } + + public void setVersion(long version) { + this.version = version; + } } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/CassandraVersion.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/CassandraVersion.java index 58e2400bc..0bb67305d 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/CassandraVersion.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/CassandraVersion.java @@ -15,8 +15,6 @@ */ package org.springframework.data.cassandra.support; -import lombok.experimental.UtilityClass; - import org.springframework.data.util.Version; import org.springframework.util.Assert; @@ -29,8 +27,7 @@ * * @author Mark Paluch */ -@UtilityClass -public class CassandraVersion { +public final class CassandraVersion { /** * Retrieve the Cassandra release version. diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/CqlDataSet.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/CqlDataSet.java index fecaf9027..458274c4f 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/CqlDataSet.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/CqlDataSet.java @@ -15,8 +15,7 @@ */ package org.springframework.data.cassandra.support; -import lombok.SneakyThrows; - +import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; import java.util.List; @@ -52,9 +51,12 @@ public List getCqlStatements() { return getLines(); } - @SneakyThrows private List getLines() { - return Resources.readLines(location, Charset.defaultCharset()); + try { + return Resources.readLines(location, Charset.defaultCharset()); + } catch (IOException e) { + throw new RuntimeException(e); + } } /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/UserDefinedTypeBuilder.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/UserDefinedTypeBuilder.java index 2690aeb3e..b4fc59353 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/UserDefinedTypeBuilder.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/support/UserDefinedTypeBuilder.java @@ -17,15 +17,9 @@ import java.util.ArrayList; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; -import org.springframework.lang.NonNull; -import org.springframework.lang.Nullable; - import com.datastax.oss.driver.api.core.CqlIdentifier; -import com.datastax.oss.driver.api.core.data.UdtValue; -import com.datastax.oss.driver.api.core.detach.AttachmentPoint; import com.datastax.oss.driver.api.core.type.DataType; import com.datastax.oss.driver.api.core.type.UserDefinedType; import com.datastax.oss.driver.internal.core.type.DefaultUserDefinedType; @@ -64,103 +58,4 @@ public UserDefinedType build() { return type; } - private static class UserDefinedTypeWrapper implements UserDefinedType { - private final UserDefinedType delegate; - - private UserDefinedTypeWrapper(UserDefinedType delegate) { - this.delegate = delegate; - } - - @Override - public void attach(@NonNull AttachmentPoint attachmentPoint) { - throw new UnsupportedOperationException(); - } - - @Override - @Nullable - public CqlIdentifier getKeyspace() { - return null; - } - - @Override - @NonNull - public CqlIdentifier getName() { - return delegate.getName(); - } - - @Override - public boolean isFrozen() { - return delegate.isFrozen(); - } - - @Override - public boolean isDetached() { - return delegate.isDetached(); - } - - @Override - @NonNull - public List getFieldNames() { - return delegate.getFieldNames(); - } - - @Override - public int firstIndexOf(CqlIdentifier id) { - return delegate.firstIndexOf(id); - } - - @Override - public int firstIndexOf(String name) { - return delegate.firstIndexOf(name); - } - - @Override - @NonNull - public List getFieldTypes() { - return delegate.getFieldTypes(); - } - - @Override - @NonNull - public UserDefinedType copy(boolean newFrozen) { - return new UserDefinedTypeWrapper(delegate.copy(newFrozen)); - } - - @Override - @NonNull - public UdtValue newValue() { - return delegate.newValue(); - } - - @Override - @NonNull - public UdtValue newValue(@NonNull Object... fields) { - return delegate.newValue(fields); - } - - @Override - public int hashCode() { - return delegate.hashCode(); - } - - @Override - public boolean equals(@Nullable Object obj) { - return super.equals(obj) || delegate.equals(obj); - } - - @Override - @NonNull - public AttachmentPoint getAttachmentPoint() { - return delegate.getAttachmentPoint(); - } - - @Override - public String toString() { - final StringBuffer sb = new StringBuffer(); - sb.append(getClass().getSimpleName()); - sb.append(" [delegate=").append(delegate); - sb.append(']'); - return sb.toString(); - } - } }