diff --git a/src/main/java/org/springframework/data/auditing/DefaultAuditableBeanWrapperFactory.java b/src/main/java/org/springframework/data/auditing/DefaultAuditableBeanWrapperFactory.java index 52cd7004e..622a8b660 100644 --- a/src/main/java/org/springframework/data/auditing/DefaultAuditableBeanWrapperFactory.java +++ b/src/main/java/org/springframework/data/auditing/DefaultAuditableBeanWrapperFactory.java @@ -15,9 +15,6 @@ */ package org.springframework.data.auditing; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.lang.reflect.Field; import java.time.Instant; import java.time.temporal.TemporalAccessor; @@ -100,7 +97,7 @@ class DefaultAuditableBeanWrapperFactory implements AuditableBeanWrapperFactory static class AuditableInterfaceBeanWrapper extends DateConvertingAuditableBeanWrapper> { - private final @NonNull Auditable auditable; + private final Auditable auditable; private final Class type; @SuppressWarnings("unchecked") @@ -187,11 +184,14 @@ class DefaultAuditableBeanWrapperFactory implements AuditableBeanWrapperFactory * @author Oliver Gierke * @since 1.8 */ - @RequiredArgsConstructor abstract static class DateConvertingAuditableBeanWrapper implements AuditableBeanWrapper { private final ConversionService conversionService; + DateConvertingAuditableBeanWrapper(ConversionService conversionService) { + this.conversionService = conversionService; + } + /** * Returns the {@link TemporalAccessor} in a type, compatible to the given field. * diff --git a/src/main/java/org/springframework/data/convert/CustomConversions.java b/src/main/java/org/springframework/data/convert/CustomConversions.java index 6a2feb935..10382fde2 100644 --- a/src/main/java/org/springframework/data/convert/CustomConversions.java +++ b/src/main/java/org/springframework/data/convert/CustomConversions.java @@ -15,13 +15,6 @@ */ package org.springframework.data.convert; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.Value; -import lombok.extern.slf4j.Slf4j; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -37,6 +30,8 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; +import org.slf4j.Logger; + import org.springframework.core.GenericTypeResolver; import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.ConverterFactory; @@ -49,6 +44,7 @@ import org.springframework.data.mapping.model.SimpleTypeHolder; import org.springframework.data.util.Streamable; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Value object to capture custom conversion. That is essentially a {@link List} of converters and some additional logic @@ -62,9 +58,9 @@ import org.springframework.util.Assert; * @author Mark Paluch * @since 2.0 */ -@Slf4j public class CustomConversions { + private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(CustomConversions.class); private static final String READ_CONVERTER_NOT_SIMPLE = "Registering converter from %s to %s as reading converter although it doesn't convert from a store-supported type! You might want to check your annotation setup at the converter implementation."; private static final String WRITE_CONVERTER_NOT_SIMPLE = "Registering converter from %s to %s as writing converter although it doesn't convert to a store-supported type! You might want to check your annotation setup at the converter implementation."; private static final String NOT_A_CONVERTER = "Converter %s is neither a Spring Converter, GenericConverter or ConverterFactory!"; @@ -511,12 +507,15 @@ public class CustomConversions { * * @author Mark Paluch */ - @RequiredArgsConstructor static class TargetTypes { - private final @NonNull Class sourceType; + private final Class sourceType; private final Map, Class> conversionTargets = new ConcurrentHashMap<>(); + TargetTypes(Class sourceType) { + this.sourceType = sourceType; + } + /** * Get or compute a target type given its {@code targetType}. Returns a cached {@link Optional} if the value * (present/absent target) was computed once. Otherwise, uses a {@link Function mappingFunction} to determine a @@ -624,15 +623,23 @@ public class CustomConversions { * @author Oliver Gierke * @author Mark Paluch */ - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) private static class ConverterRegistration { private final Object converter; - private final @NonNull ConvertiblePair convertiblePair; - private final @NonNull StoreConversions storeConversions; + private final ConvertiblePair convertiblePair; + private final StoreConversions storeConversions; private final boolean reading; private final boolean writing; + private ConverterRegistration(Object converter, ConvertiblePair convertiblePair, StoreConversions storeConversions, + boolean reading, boolean writing) { + this.converter = converter; + this.convertiblePair = convertiblePair; + this.storeConversions = storeConversions; + this.reading = reading; + this.writing = writing; + } + /** * Returns whether the converter shall be used for writing. * @@ -692,15 +699,18 @@ public class CustomConversions { * * @author Oliver Gierke */ - @Value - @Getter(AccessLevel.PACKAGE) - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) public static class StoreConversions { public static final StoreConversions NONE = StoreConversions.of(SimpleTypeHolder.DEFAULT, Collections.emptyList()); - SimpleTypeHolder storeTypeHolder; - Collection storeConverters; + private final SimpleTypeHolder storeTypeHolder; + private final Collection storeConverters; + + private StoreConversions(SimpleTypeHolder storeTypeHolder, Collection storeConverters) { + + this.storeTypeHolder = storeTypeHolder; + this.storeConverters = storeConverters; + } /** * Creates a new {@link StoreConversions} for the given store-specific {@link SimpleTypeHolder} and the given @@ -800,6 +810,57 @@ public class CustomConversions { private boolean isStoreSimpleType(Class type) { return storeTypeHolder.isSimpleType(type); } + + SimpleTypeHolder getStoreTypeHolder() { + return this.storeTypeHolder; + } + + Collection getStoreConverters() { + return this.storeConverters; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof StoreConversions)) { + return false; + } + + StoreConversions that = (StoreConversions) o; + if (!ObjectUtils.nullSafeEquals(storeTypeHolder, that.storeTypeHolder)) { + return false; + } + + return ObjectUtils.nullSafeEquals(storeConverters, that.storeConverters); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(storeTypeHolder); + result = 31 * result + ObjectUtils.nullSafeHashCode(storeConverters); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "StoreConversions{" + "storeTypeHolder=" + storeTypeHolder + ", storeConverters=" + storeConverters + '}'; + } } /** diff --git a/src/main/java/org/springframework/data/convert/DefaultConverterBuilder.java b/src/main/java/org/springframework/data/convert/DefaultConverterBuilder.java index b3a5cbd4a..b89ad8c4b 100644 --- a/src/main/java/org/springframework/data/convert/DefaultConverterBuilder.java +++ b/src/main/java/org/springframework/data/convert/DefaultConverterBuilder.java @@ -15,20 +15,12 @@ */ package org.springframework.data.convert; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.With; - import java.util.Collections; import java.util.Optional; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; -import javax.annotation.Nonnull; - import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.GenericConverter; @@ -38,6 +30,7 @@ import org.springframework.data.convert.ConverterBuilder.ReadingConverterBuilder import org.springframework.data.convert.ConverterBuilder.WritingConverterBuilder; import org.springframework.data.util.Optionals; import org.springframework.lang.Nullable; +import org.springframework.util.ObjectUtils; /** * Builder to easily set up (bi-directional) {@link Converter} instances for Spring Data type mapping using Lambdas. Use @@ -50,14 +43,20 @@ import org.springframework.lang.Nullable; * @see ConverterBuilder#reading(Class, Class, Function) * @soundtrack John Mayer - Still Feel Like Your Man (The Search for Everything) */ -@With(AccessLevel.PACKAGE) -@RequiredArgsConstructor(access = AccessLevel.PACKAGE) +@SuppressWarnings("OptionalUsedAsFieldOrParameterType") class DefaultConverterBuilder implements ConverterAware, ReadingConverterBuilder, WritingConverterBuilder { - private final @NonNull ConvertiblePair convertiblePair; - private final @NonNull Optional> writing; - private final @NonNull Optional> reading; + private final ConvertiblePair convertiblePair; + private final Optional> writing; + private final Optional> reading; + + DefaultConverterBuilder(ConvertiblePair convertiblePair, Optional> writing, + Optional> reading) { + this.convertiblePair = convertiblePair; + this.writing = writing; + this.reading = reading; + } /* * (non-Javadoc) @@ -121,13 +120,26 @@ class DefaultConverterBuilder return new ConvertiblePair(convertiblePair.getTargetType(), convertiblePair.getSourceType()); } - @RequiredArgsConstructor - @EqualsAndHashCode + DefaultConverterBuilder withWriting(Optional> writing) { + return this.writing == writing ? this + : new DefaultConverterBuilder(this.convertiblePair, writing, this.reading); + } + + DefaultConverterBuilder withReading(Optional> reading) { + return this.reading == reading ? this + : new DefaultConverterBuilder(this.convertiblePair, this.writing, reading); + } + private static class ConfigurableGenericConverter implements GenericConverter { private final ConvertiblePair convertiblePair; private final Function function; + public ConfigurableGenericConverter(ConvertiblePair convertiblePair, Function function) { + this.convertiblePair = convertiblePair; + this.function = function; + } + /* * (non-Javadoc) * @see org.springframework.core.convert.converter.GenericConverter#convert(java.lang.Object, org.springframework.core.convert.TypeDescriptor, org.springframework.core.convert.TypeDescriptor) @@ -143,12 +155,47 @@ class DefaultConverterBuilder * (non-Javadoc) * @see org.springframework.core.convert.converter.GenericConverter#getConvertibleTypes() */ - @Nonnull + @Override public Set getConvertibleTypes() { return Collections.singleton(convertiblePair); } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof ConfigurableGenericConverter)) { + return false; + } + + ConfigurableGenericConverter that = (ConfigurableGenericConverter) o; + + if (!ObjectUtils.nullSafeEquals(convertiblePair, that.convertiblePair)) { + return false; + } + + return ObjectUtils.nullSafeEquals(function, that.function); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(convertiblePair); + result = 31 * result + ObjectUtils.nullSafeHashCode(function); + return result; + } + @WritingConverter private static class Writing extends ConfigurableGenericConverter { diff --git a/src/main/java/org/springframework/data/convert/EntityInstantiatorAdapter.java b/src/main/java/org/springframework/data/convert/EntityInstantiatorAdapter.java index 965daebb8..08088b96b 100644 --- a/src/main/java/org/springframework/data/convert/EntityInstantiatorAdapter.java +++ b/src/main/java/org/springframework/data/convert/EntityInstantiatorAdapter.java @@ -15,8 +15,6 @@ */ package org.springframework.data.convert; -import lombok.RequiredArgsConstructor; - import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentProperty; import org.springframework.data.mapping.model.ParameterValueProvider; @@ -26,11 +24,14 @@ import org.springframework.data.mapping.model.ParameterValueProvider; * * @author Oliver Drotbohm */ -@RequiredArgsConstructor class EntityInstantiatorAdapter implements EntityInstantiator { private final org.springframework.data.mapping.model.EntityInstantiator delegate; + EntityInstantiatorAdapter(org.springframework.data.mapping.model.EntityInstantiator delegate) { + this.delegate = delegate; + } + /* * (non-Javadoc) * @see org.springframework.data.mapping.model.EntityInstantiator#createInstance(org.springframework.data.mapping.PersistentEntity, org.springframework.data.mapping.model.ParameterValueProvider) diff --git a/src/main/java/org/springframework/data/domain/AbstractPageRequest.java b/src/main/java/org/springframework/data/domain/AbstractPageRequest.java index ab090de01..4f99fbf39 100644 --- a/src/main/java/org/springframework/data/domain/AbstractPageRequest.java +++ b/src/main/java/org/springframework/data/domain/AbstractPageRequest.java @@ -17,8 +17,6 @@ package org.springframework.data.domain; import java.io.Serializable; -import org.springframework.lang.Nullable; - /** * Abstract Java Bean implementation of {@code Pageable}. * @@ -134,7 +132,7 @@ public abstract class AbstractPageRequest implements Pageable, Serializable { * @see java.lang.Object#equals(java.lang.Object) */ @Override - public boolean equals(@Nullable Object obj) { + public boolean equals(Object obj) { if (this == obj) { return true; diff --git a/src/main/java/org/springframework/data/domain/Chunk.java b/src/main/java/org/springframework/data/domain/Chunk.java index 8508ce089..11e5aeca1 100644 --- a/src/main/java/org/springframework/data/domain/Chunk.java +++ b/src/main/java/org/springframework/data/domain/Chunk.java @@ -15,8 +15,6 @@ */ package org.springframework.data.domain; -import lombok.Getter; - import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; @@ -25,7 +23,6 @@ import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; -import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -40,7 +37,7 @@ abstract class Chunk implements Slice, Serializable { private static final long serialVersionUID = 867755909294344406L; private final List content = new ArrayList<>(); - private final @Getter Pageable pageable; + private final Pageable pageable; /** * Creates a new {@link Chunk} with the given content and the given governing {@link Pageable}. @@ -137,6 +134,15 @@ abstract class Chunk implements Slice, Serializable { return Collections.unmodifiableList(content); } + /* + * (non-Javadoc) + * @see org.springframework.data.domain.Slice#getPageable() + */ + @Override + public Pageable getPageable() { + return pageable; + } + /* * (non-Javadoc) * @see org.springframework.data.domain.Slice#getSort() @@ -172,7 +178,7 @@ abstract class Chunk implements Slice, Serializable { * @see java.lang.Object#equals(java.lang.Object) */ @Override - public boolean equals(@Nullable Object obj) { + public boolean equals(Object obj) { if (this == obj) { return true; diff --git a/src/main/java/org/springframework/data/domain/ExampleMatcher.java b/src/main/java/org/springframework/data/domain/ExampleMatcher.java index ce5c709fd..5d2b9e05a 100644 --- a/src/main/java/org/springframework/data/domain/ExampleMatcher.java +++ b/src/main/java/org/springframework/data/domain/ExampleMatcher.java @@ -15,11 +15,6 @@ */ package org.springframework.data.domain; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; -import lombok.experimental.FieldDefaults; - import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; @@ -29,6 +24,7 @@ import java.util.function.Function; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Specification for property path matching to use in query by example (QBE). An {@link ExampleMatcher} can be created @@ -282,7 +278,6 @@ public interface ExampleMatcher { * * @author Mark Paluch */ - @EqualsAndHashCode class GenericPropertyMatcher { @Nullable StringMatcher stringMatcher = null; @@ -440,6 +435,49 @@ public interface ExampleMatcher { this.valueTransformer = propertyValueTransformer; return this; } + + protected boolean canEqual(final Object other) { + return other instanceof GenericPropertyMatcher; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof GenericPropertyMatcher)) { + return false; + } + + GenericPropertyMatcher that = (GenericPropertyMatcher) o; + + if (stringMatcher != that.stringMatcher) + return false; + + if (!ObjectUtils.nullSafeEquals(ignoreCase, that.ignoreCase)) { + return false; + } + + return ObjectUtils.nullSafeEquals(valueTransformer, that.valueTransformer); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(stringMatcher); + result = 31 * result + ObjectUtils.nullSafeHashCode(ignoreCase); + result = 31 * result + ObjectUtils.nullSafeHashCode(valueTransformer); + return result; + } } /** @@ -589,15 +627,12 @@ public interface ExampleMatcher { * @author Mark Paluch * @since 1.12 */ - @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) - @EqualsAndHashCode class PropertySpecifier { - String path; - @Nullable StringMatcher stringMatcher; - @Nullable Boolean ignoreCase; - PropertyValueTransformer valueTransformer; + private final String path; + private final @Nullable StringMatcher stringMatcher; + private final @Nullable Boolean ignoreCase; + private final PropertyValueTransformer valueTransformer; /** * Creates new {@link PropertySpecifier} for given path. @@ -614,6 +649,14 @@ public interface ExampleMatcher { this.valueTransformer = NoOpPropertyValueTransformer.INSTANCE; } + private PropertySpecifier(String path, @Nullable StringMatcher stringMatcher, @Nullable Boolean ignoreCase, + PropertyValueTransformer valueTransformer) { + this.path = path; + this.stringMatcher = stringMatcher; + this.ignoreCase = ignoreCase; + this.valueTransformer = valueTransformer; + } + /** * Creates a new {@link PropertySpecifier} containing all values from the current instance and sets * {@link StringMatcher} in the returned instance. @@ -696,6 +739,55 @@ public interface ExampleMatcher { public Optional transformValue(Optional source) { return getPropertyValueTransformer().apply(source); } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof PropertySpecifier)) { + return false; + } + + PropertySpecifier that = (PropertySpecifier) o; + + if (!ObjectUtils.nullSafeEquals(path, that.path)) { + return false; + } + + if (stringMatcher != that.stringMatcher) + return false; + + if (!ObjectUtils.nullSafeEquals(ignoreCase, that.ignoreCase)) { + return false; + } + + return ObjectUtils.nullSafeEquals(valueTransformer, that.valueTransformer); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(path); + result = 31 * result + ObjectUtils.nullSafeHashCode(stringMatcher); + result = 31 * result + ObjectUtils.nullSafeHashCode(ignoreCase); + result = 31 * result + ObjectUtils.nullSafeHashCode(valueTransformer); + return result; + } + + protected boolean canEqual(final Object other) { + return other instanceof PropertySpecifier; + } + } /** @@ -705,7 +797,6 @@ public interface ExampleMatcher { * @author Mark Paluch * @since 1.12 */ - @EqualsAndHashCode class PropertySpecifiers { private final Map propertySpecifiers = new LinkedHashMap<>(); @@ -737,6 +828,34 @@ public interface ExampleMatcher { public Collection getSpecifiers() { return propertySpecifiers.values(); } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof PropertySpecifiers)) { + return false; + } + + PropertySpecifiers that = (PropertySpecifiers) o; + return ObjectUtils.nullSafeEquals(propertySpecifiers, that.propertySpecifiers); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(propertySpecifiers); + } } /** diff --git a/src/main/java/org/springframework/data/domain/Range.java b/src/main/java/org/springframework/data/domain/Range.java index 2ca80a3fd..c186e3ccd 100644 --- a/src/main/java/org/springframework/data/domain/Range.java +++ b/src/main/java/org/springframework/data/domain/Range.java @@ -15,14 +15,10 @@ */ package org.springframework.data.domain; -import lombok.AccessLevel; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.Value; - import java.util.Optional; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Simple value object to work with ranges and boundaries. @@ -31,21 +27,28 @@ import org.springframework.util.Assert; * @author Mark Paluch * @since 1.10 */ -@Value -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public class Range> { +public final class Range> { private final static Range UNBOUNDED = Range.of(Bound.unbounded(), Bound.UNBOUNDED); /** * The lower bound of the range. */ - private final @NonNull Bound lowerBound; + private final Bound lowerBound; /** * The upper bound of the range. */ - private final @NonNull Bound upperBound; + private final Bound upperBound; + + private Range(Bound lowerBound, Bound upperBound) { + + Assert.notNull(lowerBound, "Lower bound must not be null!"); + Assert.notNull(upperBound, "Upper bound must not be null!"); + + this.lowerBound = lowerBound; + this.upperBound = upperBound; + } /** * Returns an unbounded {@link Range}. @@ -203,6 +206,49 @@ public class Range> { return String.format("%s-%s", lowerBound.toPrefixString(), upperBound.toSuffixString()); } + public Range.Bound getLowerBound() { + return this.lowerBound; + } + + public Range.Bound getUpperBound() { + return this.upperBound; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Range)) { + return false; + } + + Range range = (Range) o; + + if (!ObjectUtils.nullSafeEquals(lowerBound, range.lowerBound)) { + return false; + } + + return ObjectUtils.nullSafeEquals(upperBound, range.upperBound); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(lowerBound); + result = 31 * result + ObjectUtils.nullSafeHashCode(upperBound); + return result; + } + /** * Value object representing a boundary. A boundary can either be {@link #unbounded() unbounded}, * {@link #inclusive(Comparable) including its value} or {@link #exclusive(Comparable) its value}. @@ -211,9 +257,7 @@ public class Range> { * @since 2.0 * @soundtrack Mohamed Ragab - Excelsior Sessions (March 2017) */ - @Value - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) - public static class Bound> { + public static final class Bound> { @SuppressWarnings({ "rawtypes", "unchecked" }) // private static final Bound UNBOUNDED = new Bound(Optional.empty(), true); @@ -221,6 +265,11 @@ public class Range> { private final Optional value; private final boolean inclusive; + private Bound(Optional value, boolean inclusive) { + this.value = value; + this.inclusive = inclusive; + } + /** * Creates an unbounded {@link Bound}. */ @@ -367,6 +416,47 @@ public class Range> { return value.map(Object::toString).orElse("unbounded"); } + public Optional getValue() { + return this.value; + } + + public boolean isInclusive() { + return this.inclusive; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Bound)) { + return false; + } + + Bound bound = (Bound) o; + + if (inclusive != bound.inclusive) + return false; + + return ObjectUtils.nullSafeEquals(value, bound.value); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(value); + result = 31 * result + (inclusive ? 1 : 0); + return result; + } } /** diff --git a/src/main/java/org/springframework/data/domain/Sort.java b/src/main/java/org/springframework/data/domain/Sort.java index 0515d2f0b..44490b00f 100644 --- a/src/main/java/org/springframework/data/domain/Sort.java +++ b/src/main/java/org/springframework/data/domain/Sort.java @@ -15,9 +15,6 @@ */ package org.springframework.data.domain; -import lombok.AccessLevel; -import lombok.RequiredArgsConstructor; - import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +41,6 @@ import org.springframework.util.StringUtils; * @author Thomas Darimont * @author Mark Paluch */ -@RequiredArgsConstructor(access = AccessLevel.PROTECTED) public class Sort implements Streamable, Serializable { private static final long serialVersionUID = 5737186511678863905L; @@ -55,6 +51,10 @@ public class Sort implements Streamable orders; + protected Sort(List orders) { + this.orders = orders; + } + /** * Creates a new {@link Sort} instance. * diff --git a/src/main/java/org/springframework/data/domain/TypedExample.java b/src/main/java/org/springframework/data/domain/TypedExample.java index 356f635df..672f68fb8 100644 --- a/src/main/java/org/springframework/data/domain/TypedExample.java +++ b/src/main/java/org/springframework/data/domain/TypedExample.java @@ -15,12 +15,8 @@ */ package org.springframework.data.domain; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.ToString; +import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Default implementation of {@link Example} holing instances of {@literal probe} and {@link ExampleMatcher}. @@ -28,12 +24,68 @@ import lombok.ToString; * @author Christoph Strobl * @since 2.0 */ -@ToString -@EqualsAndHashCode -@RequiredArgsConstructor(access = AccessLevel.PACKAGE) -@Getter class TypedExample implements Example { - private final @NonNull T probe; - private final @NonNull ExampleMatcher matcher; + private final T probe; + private final ExampleMatcher matcher; + + TypedExample(T probe, ExampleMatcher matcher) { + + Assert.notNull(probe, "Probe must not be null"); + Assert.notNull(matcher, "ExampleMatcher must not be null"); + + this.probe = probe; + this.matcher = matcher; + } + + public T getProbe() { + return this.probe; + } + + public ExampleMatcher getMatcher() { + return this.matcher; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof TypedExample)) { + return false; + } + + TypedExample that = (TypedExample) o; + if (!ObjectUtils.nullSafeEquals(probe, that.probe)) { + return false; + } + + return ObjectUtils.nullSafeEquals(matcher, that.matcher); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(probe); + result = 31 * result + ObjectUtils.nullSafeHashCode(matcher); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "TypedExample{" + "probe=" + probe + ", matcher=" + matcher + '}'; + } } diff --git a/src/main/java/org/springframework/data/domain/TypedExampleMatcher.java b/src/main/java/org/springframework/data/domain/TypedExampleMatcher.java index 52bfd5cd3..9ba122cd1 100644 --- a/src/main/java/org/springframework/data/domain/TypedExampleMatcher.java +++ b/src/main/java/org/springframework/data/domain/TypedExampleMatcher.java @@ -15,18 +15,13 @@ */ package org.springframework.data.domain; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; -import lombok.ToString; -import lombok.With; - import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Default implementation of {@link ExampleMatcher}. @@ -35,9 +30,6 @@ import org.springframework.util.Assert; * @author Mark Paluch * @since 2.0 */ -@ToString -@EqualsAndHashCode -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) class TypedExampleMatcher implements ExampleMatcher { private final NullHandler nullHandler; @@ -45,7 +37,7 @@ class TypedExampleMatcher implements ExampleMatcher { private final PropertySpecifiers propertySpecifiers; private final Set ignoredPaths; private final boolean defaultIgnoreCase; - private final @With(AccessLevel.PACKAGE) MatchMode mode; + private final MatchMode mode; TypedExampleMatcher() { @@ -53,6 +45,16 @@ class TypedExampleMatcher implements ExampleMatcher { MatchMode.ALL); } + private TypedExampleMatcher(NullHandler nullHandler, StringMatcher defaultStringMatcher, + PropertySpecifiers propertySpecifiers, Set ignoredPaths, boolean defaultIgnoreCase, MatchMode mode) { + this.nullHandler = nullHandler; + this.defaultStringMatcher = defaultStringMatcher; + this.propertySpecifiers = propertySpecifiers; + this.ignoredPaths = ignoredPaths; + this.defaultIgnoreCase = defaultIgnoreCase; + this.mode = mode; + } + /* * (non-Javadoc) * @see org.springframework.data.domain.ExampleMatcher#withIgnorePaths(java.lang.String...) @@ -228,6 +230,12 @@ class TypedExampleMatcher implements ExampleMatcher { return mode; } + TypedExampleMatcher withMode(MatchMode mode) { + return this.mode == mode ? this + : new TypedExampleMatcher(this.nullHandler, this.defaultStringMatcher, this.propertySpecifiers, + this.ignoredPaths, this.defaultIgnoreCase, mode); + } + private PropertySpecifier getOrCreatePropertySpecifier(String propertyPath, PropertySpecifiers propertySpecifiers) { if (propertySpecifiers.hasSpecifierForPath(propertyPath)) { @@ -236,4 +244,71 @@ class TypedExampleMatcher implements ExampleMatcher { return new PropertySpecifier(propertyPath); } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof TypedExampleMatcher)) { + return false; + } + + TypedExampleMatcher that = (TypedExampleMatcher) o; + + if (defaultIgnoreCase != that.defaultIgnoreCase) { + return false; + } + + if (nullHandler != that.nullHandler) { + return false; + } + + if (defaultStringMatcher != that.defaultStringMatcher) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(propertySpecifiers, that.propertySpecifiers)) { + + return false; + } + + if (!ObjectUtils.nullSafeEquals(ignoredPaths, that.ignoredPaths)) { + return false; + } + + return mode == that.mode; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(nullHandler); + result = 31 * result + ObjectUtils.nullSafeHashCode(defaultStringMatcher); + result = 31 * result + ObjectUtils.nullSafeHashCode(propertySpecifiers); + result = 31 * result + ObjectUtils.nullSafeHashCode(ignoredPaths); + result = 31 * result + (defaultIgnoreCase ? 1 : 0); + result = 31 * result + ObjectUtils.nullSafeHashCode(mode); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "TypedExampleMatcher{" + "nullHandler=" + nullHandler + ", defaultStringMatcher=" + defaultStringMatcher + + ", propertySpecifiers=" + propertySpecifiers + ", ignoredPaths=" + ignoredPaths + ", defaultIgnoreCase=" + + defaultIgnoreCase + ", mode=" + mode + '}'; + } } diff --git a/src/main/java/org/springframework/data/geo/Circle.java b/src/main/java/org/springframework/data/geo/Circle.java index a59eb7422..5f62af91d 100644 --- a/src/main/java/org/springframework/data/geo/Circle.java +++ b/src/main/java/org/springframework/data/geo/Circle.java @@ -15,10 +15,9 @@ */ package org.springframework.data.geo; -import lombok.EqualsAndHashCode; - import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Represents a geospatial circle value @@ -28,7 +27,6 @@ import org.springframework.util.Assert; * @author Thomas Darimont * @since 1.8 */ -@EqualsAndHashCode public class Circle implements Shape { private static final long serialVersionUID = 5215611530535947924L; @@ -93,6 +91,41 @@ public class Circle implements Shape { return radius; } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Circle)) { + return false; + } + + Circle circle = (Circle) o; + + if (!ObjectUtils.nullSafeEquals(center, circle.center)) { + return false; + } + + return ObjectUtils.nullSafeEquals(radius, circle.radius); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(center); + result = 31 * result + ObjectUtils.nullSafeHashCode(radius); + return result; + } + /* * (non-Javadoc) * @see java.lang.Object#toString() diff --git a/src/main/java/org/springframework/data/geo/Distance.java b/src/main/java/org/springframework/data/geo/Distance.java index cf36229bf..4eaad526f 100644 --- a/src/main/java/org/springframework/data/geo/Distance.java +++ b/src/main/java/org/springframework/data/geo/Distance.java @@ -15,14 +15,13 @@ */ package org.springframework.data.geo; -import lombok.Value; - import java.io.Serializable; import org.springframework.data.domain.Range; import org.springframework.data.domain.Range.Bound; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Value object to represent distances in a given metric. @@ -31,8 +30,7 @@ import org.springframework.util.Assert; * @author Thomas Darimont * @since 1.8 */ -@Value -public class Distance implements Serializable, Comparable { +public final class Distance implements Serializable, Comparable { private static final long serialVersionUID = 2460886201934027744L; @@ -192,4 +190,49 @@ public class Distance implements Serializable, Comparable { return builder.toString(); } + + public double getValue() { + return this.value; + } + + public Metric getMetric() { + return this.metric; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Distance)) { + return false; + } + + Distance distance = (Distance) o; + + if (value != distance.value) { + return false; + } + return ObjectUtils.nullSafeEquals(metric, distance.metric); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result; + long temp; + temp = Double.doubleToLongBits(value); + result = (int) (temp ^ (temp >>> 32)); + result = 31 * result + ObjectUtils.nullSafeHashCode(metric); + return result; + } } diff --git a/src/main/java/org/springframework/data/geo/GeoPage.java b/src/main/java/org/springframework/data/geo/GeoPage.java index 5e1301a41..70afb84c4 100644 --- a/src/main/java/org/springframework/data/geo/GeoPage.java +++ b/src/main/java/org/springframework/data/geo/GeoPage.java @@ -15,8 +15,6 @@ */ package org.springframework.data.geo; -import lombok.Getter; - import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -38,7 +36,7 @@ public class GeoPage extends PageImpl> { /** * The average distance of the underlying results. */ - private final @Getter Distance averageDistance; + private final Distance averageDistance; /** * Creates a new {@link GeoPage} from the given {@link GeoResults}. @@ -94,4 +92,8 @@ public class GeoPage extends PageImpl> { public int hashCode() { return super.hashCode() + ObjectUtils.nullSafeHashCode(this.averageDistance); } + + public Distance getAverageDistance() { + return this.averageDistance; + } } diff --git a/src/main/java/org/springframework/data/geo/GeoResult.java b/src/main/java/org/springframework/data/geo/GeoResult.java index 685b3d46a..cc1703e0f 100644 --- a/src/main/java/org/springframework/data/geo/GeoResult.java +++ b/src/main/java/org/springframework/data/geo/GeoResult.java @@ -15,11 +15,11 @@ */ package org.springframework.data.geo; -import lombok.NonNull; -import lombok.Value; - import java.io.Serializable; +import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; + /** * Value object capturing some arbitrary object plus a distance. * @@ -27,13 +27,64 @@ import java.io.Serializable; * @author Thomas Darimont * @since 1.8 */ -@Value -public class GeoResult implements Serializable { +public final class GeoResult implements Serializable { private static final long serialVersionUID = 1637452570977581370L; - @NonNull T content; - @NonNull Distance distance; + private final T content; + private final Distance distance; + + public GeoResult(T content, Distance distance) { + + Assert.notNull(content, "Content must not be null"); + Assert.notNull(distance, "Distance must not be null"); + + this.content = content; + this.distance = distance; + } + + public T getContent() { + return this.content; + } + + public Distance getDistance() { + return this.distance; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof GeoResult)) { + return false; + } + + GeoResult geoResult = (GeoResult) o; + + if (!ObjectUtils.nullSafeEquals(content, geoResult.content)) { + return false; + } + + return ObjectUtils.nullSafeEquals(distance, geoResult.distance); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(content); + result = 31 * result + ObjectUtils.nullSafeHashCode(distance); + return result; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/geo/GeoResults.java b/src/main/java/org/springframework/data/geo/GeoResults.java index 2dd3f82e5..25120e163 100644 --- a/src/main/java/org/springframework/data/geo/GeoResults.java +++ b/src/main/java/org/springframework/data/geo/GeoResults.java @@ -15,7 +15,6 @@ */ package org.springframework.data.geo; -import lombok.EqualsAndHashCode; import java.io.Serializable; import java.util.Collections; @@ -24,6 +23,7 @@ import java.util.List; import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** @@ -33,7 +33,6 @@ import org.springframework.util.StringUtils; * @author Thomas Darimont * @since 1.8 */ -@EqualsAndHashCode public class GeoResults implements Iterable>, Serializable { private static final long serialVersionUID = 8347363491300219485L; @@ -105,6 +104,41 @@ public class GeoResults implements Iterable>, Serializable { return (Iterator>) results.iterator(); } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof GeoResults)) { + return false; + } + + GeoResults that = (GeoResults) o; + + if (!ObjectUtils.nullSafeEquals(results, that.results)) { + return false; + } + + return ObjectUtils.nullSafeEquals(averageDistance, that.averageDistance); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(results); + result = 31 * result + ObjectUtils.nullSafeHashCode(averageDistance); + return result; + } + /* * (non-Javadoc) * @see java.lang.Object#toString() diff --git a/src/main/java/org/springframework/data/geo/Polygon.java b/src/main/java/org/springframework/data/geo/Polygon.java index bae31bb45..dfe50847b 100644 --- a/src/main/java/org/springframework/data/geo/Polygon.java +++ b/src/main/java/org/springframework/data/geo/Polygon.java @@ -15,7 +15,6 @@ */ package org.springframework.data.geo; -import lombok.EqualsAndHashCode; import java.util.ArrayList; import java.util.Arrays; @@ -25,6 +24,7 @@ import java.util.List; import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** @@ -34,7 +34,6 @@ import org.springframework.util.StringUtils; * @author Thomas Darimont * @since 1.8 */ -@EqualsAndHashCode public class Polygon implements Iterable, Shape { private static final long serialVersionUID = -2705040068154648988L; @@ -101,6 +100,34 @@ public class Polygon implements Iterable, Shape { return this.points.iterator(); } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Polygon)) { + return false; + } + + Polygon that = (Polygon) o; + return ObjectUtils.nullSafeEquals(points, that.points); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(points); + } + /* * (non-Javadoc) * @see java.lang.Object#toString() diff --git a/src/main/java/org/springframework/data/history/Revision.java b/src/main/java/org/springframework/data/history/Revision.java index 630831306..6c762e714 100755 --- a/src/main/java/org/springframework/data/history/Revision.java +++ b/src/main/java/org/springframework/data/history/Revision.java @@ -17,15 +17,11 @@ package org.springframework.data.history; import static org.springframework.data.util.Optionals.*; -import lombok.AccessLevel; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.Value; - import java.time.Instant; import java.util.Optional; import org.springframework.lang.Nullable; +import org.springframework.util.ObjectUtils; /** * Wrapper to contain {@link RevisionMetadata} as well as the revisioned entity. @@ -35,19 +31,23 @@ import org.springframework.lang.Nullable; * @author Christoph Strobl * @author Jens Schauder */ -@Value -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) public final class Revision, T> implements Comparable> { /** * The {@link RevisionMetadata} for the current {@link Revision}. */ - @NonNull RevisionMetadata metadata; + private final RevisionMetadata metadata; /** * The underlying entity. */ - @NonNull T entity; + + private final T entity; + + private Revision(RevisionMetadata metadata, T entity) { + this.metadata = metadata; + this.entity = entity; + } /** * Creates a new {@link Revision} for the given {@link RevisionMetadata} and entity. @@ -116,8 +116,50 @@ public final class Revision, T> implements Comp */ @Override public String toString() { - return String.format("Revision %s of entity %s - Revision metadata %s", getRevisionNumber().map(Object::toString).orElse(""), entity, metadata); } + + public RevisionMetadata getMetadata() { + return this.metadata; + } + + public T getEntity() { + return this.entity; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Revision)) { + return false; + } + + Revision revision = (Revision) o; + + if (!ObjectUtils.nullSafeEquals(metadata, revision.metadata)) { + return false; + } + + return ObjectUtils.nullSafeEquals(entity, revision.entity); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(metadata); + result = 31 * result + ObjectUtils.nullSafeHashCode(entity); + return result; + } } diff --git a/src/main/java/org/springframework/data/mapping/AccessOptions.java b/src/main/java/org/springframework/data/mapping/AccessOptions.java index 0a09dc9df..84635f3e8 100644 --- a/src/main/java/org/springframework/data/mapping/AccessOptions.java +++ b/src/main/java/org/springframework/data/mapping/AccessOptions.java @@ -15,10 +15,6 @@ */ package org.springframework.data.mapping; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.With; - import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -64,13 +60,26 @@ public class AccessOptions { * * @author Oliver Drotbohm */ - @AllArgsConstructor public static class GetOptions { private static final GetOptions DEFAULT = new GetOptions(new HashMap<>(), GetNulls.REJECT); private final Map, Function> handlers; - private final @With @Getter GetNulls nullValues; + private final GetNulls nullValues; + + public GetOptions(Map, Function> handlers, GetNulls nullValues) { + + this.handlers = handlers; + this.nullValues = nullValues; + } + + public GetNulls getNullValues() { + return this.nullValues; + } + + public GetOptions withNullValues(GetNulls nullValues) { + return this.nullValues == nullValues ? this : new GetOptions(this.handlers, nullValues); + } /** * How to handle null values during a {@link PersistentPropertyPath} traversal. @@ -203,10 +212,33 @@ public class AccessOptions { * * @author Oliver Drotbohm */ - @With - @AllArgsConstructor public static class SetOptions { + public SetOptions(SetNulls nullHandling, Propagation collectionPropagation, Propagation mapPropagation) { + this.nullHandling = nullHandling; + this.collectionPropagation = collectionPropagation; + this.mapPropagation = mapPropagation; + } + + public SetOptions withNullHandling(SetNulls nullHandling) { + return this.nullHandling == nullHandling ? this + : new SetOptions(nullHandling, this.collectionPropagation, this.mapPropagation); + } + + public SetOptions withCollectionPropagation(Propagation collectionPropagation) { + return this.collectionPropagation == collectionPropagation ? this + : new SetOptions(this.nullHandling, collectionPropagation, this.mapPropagation); + } + + public SetOptions withMapPropagation(Propagation mapPropagation) { + return this.mapPropagation == mapPropagation ? this + : new SetOptions(this.nullHandling, this.collectionPropagation, mapPropagation); + } + + public SetNulls getNullHandling() { + return this.nullHandling; + } + /** * How to handle intermediate {@literal null} values when setting * @@ -252,7 +284,7 @@ public class AccessOptions { private static final SetOptions DEFAULT = new SetOptions(); - private final @Getter SetNulls nullHandling; + private final SetNulls nullHandling; private final Propagation collectionPropagation, mapPropagation; private SetOptions() { diff --git a/src/main/java/org/springframework/data/mapping/Alias.java b/src/main/java/org/springframework/data/mapping/Alias.java index 3d5ddef26..85a7f9c09 100644 --- a/src/main/java/org/springframework/data/mapping/Alias.java +++ b/src/main/java/org/springframework/data/mapping/Alias.java @@ -15,12 +15,9 @@ */ package org.springframework.data.mapping; -import lombok.AccessLevel; -import lombok.RequiredArgsConstructor; -import lombok.Value; - import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * A container object which may or may not contain a type alias value. If a value is present, {@code isPresent()} will @@ -35,9 +32,7 @@ import org.springframework.util.Assert; * @author Christoph Strobl * @author Mark Paluch */ -@Value -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public class Alias { +public final class Alias { /** * Common instance for {@code empty()}. @@ -47,6 +42,10 @@ public class Alias { private final Object value; + private Alias(Object value) { + this.value = value; + } + /** * Create an {@link Alias} given the {@code alias} object. * @@ -143,4 +142,36 @@ public class Alias { public String toString() { return isPresent() ? value.toString() : "NONE"; } + + public Object getValue() { + return this.value; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Alias)) { + return false; + } + + Alias alias = (Alias) o; + return ObjectUtils.nullSafeEquals(value, alias.value); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(value); + } } diff --git a/src/main/java/org/springframework/data/mapping/PreferredConstructor.java b/src/main/java/org/springframework/data/mapping/PreferredConstructor.java index c6478f53c..b0fcc938f 100644 --- a/src/main/java/org/springframework/data/mapping/PreferredConstructor.java +++ b/src/main/java/org/springframework/data/mapping/PreferredConstructor.java @@ -15,8 +15,6 @@ */ package org.springframework.data.mapping; -import lombok.EqualsAndHashCode; - import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.util.Arrays; @@ -32,6 +30,7 @@ import org.springframework.data.util.Lazy; import org.springframework.data.util.TypeInformation; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; @@ -186,7 +185,6 @@ public class PreferredConstructor> { * @param the type of the parameter * @author Oliver Gierke */ - @EqualsAndHashCode(exclude = { "enclosingClassCache", "hasSpelExpression" }) public static class Parameter> { private final @Nullable String name; @@ -285,6 +283,51 @@ public class PreferredConstructor> { return this.hasSpelExpression.get(); } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Parameter)) { + return false; + } + + Parameter parameter = (Parameter) o; + + if (!ObjectUtils.nullSafeEquals(name, parameter.name)) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(type, parameter.type)) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(key, parameter.key)) { + return false; + } + + return ObjectUtils.nullSafeEquals(entity, parameter.entity); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(name); + result = 31 * result + ObjectUtils.nullSafeHashCode(type); + result = 31 * result + ObjectUtils.nullSafeHashCode(key); + result = 31 * result + ObjectUtils.nullSafeHashCode(entity); + return result; + } + /** * Returns whether the {@link Parameter} maps the given {@link PersistentProperty}. * diff --git a/src/main/java/org/springframework/data/mapping/PropertyPath.java b/src/main/java/org/springframework/data/mapping/PropertyPath.java index 8afee7d6f..5359e0c39 100644 --- a/src/main/java/org/springframework/data/mapping/PropertyPath.java +++ b/src/main/java/org/springframework/data/mapping/PropertyPath.java @@ -15,10 +15,6 @@ */ package org.springframework.data.mapping; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Value; - import java.beans.Introspector; import java.util.ArrayList; import java.util.Collections; @@ -35,6 +31,7 @@ import org.springframework.data.util.TypeInformation; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ConcurrentReferenceHashMap; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** @@ -45,7 +42,6 @@ import org.springframework.util.StringUtils; * @author Mark Paluch * @author Mariusz MÄ…czkowski */ -@EqualsAndHashCode public class PropertyPath implements Streamable { private static final String PARSE_DEPTH_EXCEEDED = "Trying to parse a path with depth greater than 1000! This has been disabled for security reasons to prevent parsing overflows."; @@ -58,7 +54,7 @@ public class PropertyPath implements Streamable { private final TypeInformation owningType; private final String name; - private final @Getter TypeInformation typeInformation; + private final TypeInformation typeInformation; private final TypeInformation actualTypeInformation; private final boolean isCollection; @@ -155,6 +151,10 @@ public class PropertyPath implements Streamable { return this.actualTypeInformation.getType(); } + public TypeInformation getTypeInformation() { + return this.typeInformation; + } + /** * Returns the next nested {@link PropertyPath}. * @@ -247,6 +247,61 @@ public class PropertyPath implements Streamable { }; } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof PropertyPath)) { + return false; + } + + PropertyPath that = (PropertyPath) o; + + if (isCollection != that.isCollection) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(owningType, that.owningType)) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(name, that.name)) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(typeInformation, that.typeInformation)) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(actualTypeInformation, that.actualTypeInformation)) { + return false; + } + + return ObjectUtils.nullSafeEquals(next, that.next); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(owningType); + result = 31 * result + ObjectUtils.nullSafeHashCode(name); + result = 31 * result + ObjectUtils.nullSafeHashCode(typeInformation); + result = 31 * result + ObjectUtils.nullSafeHashCode(actualTypeInformation); + result = 31 * result + (isCollection ? 1 : 0); + result = 31 * result + ObjectUtils.nullSafeHashCode(next); + return result; + } + /** * Returns the next {@link PropertyPath}. * @@ -431,10 +486,70 @@ public class PropertyPath implements Streamable { return String.format("%s.%s", owningType.getType().getSimpleName(), toDotPath()); } - @Value(staticConstructor = "of") - private static class Key { + private static final class Key { - TypeInformation type; - String path; + private final TypeInformation type; + private final String path; + + private Key(TypeInformation type, String path) { + this.type = type; + this.path = path; + } + + public static Key of(TypeInformation type, String path) { + return new Key(type, path); + } + + public TypeInformation getType() { + return this.type; + } + + public String getPath() { + return this.path; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Key)) { + return false; + } + + Key key = (Key) o; + + if (!ObjectUtils.nullSafeEquals(type, key.type)) { + return false; + } + + return ObjectUtils.nullSafeEquals(path, key.path); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(type); + result = 31 * result + ObjectUtils.nullSafeHashCode(path); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "PropertyPath.Key(type=" + this.getType() + ", path=" + this.getPath() + ")"; + } } } diff --git a/src/main/java/org/springframework/data/mapping/TargetAwareIdentifierAccessor.java b/src/main/java/org/springframework/data/mapping/TargetAwareIdentifierAccessor.java index 2fce34141..88bda5b00 100644 --- a/src/main/java/org/springframework/data/mapping/TargetAwareIdentifierAccessor.java +++ b/src/main/java/org/springframework/data/mapping/TargetAwareIdentifierAccessor.java @@ -15,8 +15,6 @@ */ package org.springframework.data.mapping; -import lombok.RequiredArgsConstructor; - /** * {@link IdentifierAccessor} that is aware of the target bean to obtain the identifier from so that it can generate a * more meaningful exception in case of an absent identifier and a call to {@link #getRequiredIdentifier()}. @@ -26,11 +24,14 @@ import lombok.RequiredArgsConstructor; * @since 2.0 * @soundtrack Anika Nilles - Greenfield (Pikalar) */ -@RequiredArgsConstructor public abstract class TargetAwareIdentifierAccessor implements IdentifierAccessor { private final Object target; + public TargetAwareIdentifierAccessor(Object target) { + this.target = target; + } + /* * (non-Javadoc) * @see org.springframework.data.mapping.IdentifierAccessor#getRequiredIdentifier() diff --git a/src/main/java/org/springframework/data/mapping/callback/EntityCallbackDiscoverer.java b/src/main/java/org/springframework/data/mapping/callback/EntityCallbackDiscoverer.java index d92233eca..ad65c6de0 100644 --- a/src/main/java/org/springframework/data/mapping/callback/EntityCallbackDiscoverer.java +++ b/src/main/java/org/springframework/data/mapping/callback/EntityCallbackDiscoverer.java @@ -440,6 +440,10 @@ class EntityCallbackDiscoverer { this.entityType = entityType; } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ @Override public boolean equals(Object other) { @@ -453,6 +457,10 @@ class EntityCallbackDiscoverer { && ObjectUtils.nullSafeEquals(this.entityType, otherKey.entityType)); } + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ @Override public int hashCode() { return this.callbackType.hashCode() * 17 + ObjectUtils.nullSafeHashCode(this.entityType); diff --git a/src/main/java/org/springframework/data/mapping/context/AbstractMappingContext.java b/src/main/java/org/springframework/data/mapping/context/AbstractMappingContext.java index 54560f4d4..52bd769ae 100644 --- a/src/main/java/org/springframework/data/mapping/context/AbstractMappingContext.java +++ b/src/main/java/org/springframework/data/mapping/context/AbstractMappingContext.java @@ -15,10 +15,6 @@ */ package org.springframework.data.mapping.context; -import lombok.AccessLevel; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -487,17 +483,23 @@ public abstract class AbstractMappingContext descriptors; - private final @NonNull Map remainingDescriptors; + private final E entity; + private final Map descriptors; + private final Map remainingDescriptors; public PersistentPropertyCreator(E entity, Map descriptors) { this(entity, descriptors, descriptors); } + private PersistentPropertyCreator(E entity, Map descriptors, + Map remainingDescriptors) { + this.entity = entity; + this.descriptors = descriptors; + this.remainingDescriptors = remainingDescriptors; + } + /* * (non-Javadoc) * @see org.springframework.util.ReflectionUtils.FieldCallback#doWith(java.lang.reflect.Field) diff --git a/src/main/java/org/springframework/data/mapping/context/DefaultPersistentPropertyPath.java b/src/main/java/org/springframework/data/mapping/context/DefaultPersistentPropertyPath.java index e4a31b14e..2ce3bc7c8 100644 --- a/src/main/java/org/springframework/data/mapping/context/DefaultPersistentPropertyPath.java +++ b/src/main/java/org/springframework/data/mapping/context/DefaultPersistentPropertyPath.java @@ -15,8 +15,6 @@ */ package org.springframework.data.mapping.context; -import lombok.EqualsAndHashCode; - import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -29,6 +27,7 @@ import org.springframework.data.mapping.PersistentPropertyPath; import org.springframework.data.util.TypeInformation; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** @@ -37,7 +36,6 @@ import org.springframework.util.StringUtils; * @author Oliver Gierke * @author Christoph Strobl */ -@EqualsAndHashCode class DefaultPersistentPropertyPath

> implements PersistentPropertyPath

{ private static final Converter, String> DEFAULT_CONVERTER = (source) -> source.getName(); @@ -247,6 +245,34 @@ class DefaultPersistentPropertyPath

> implements .anyMatch(property -> type.equals(property.getTypeInformation().getActualType())); } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof DefaultPersistentPropertyPath)) { + return false; + } + + DefaultPersistentPropertyPath that = (DefaultPersistentPropertyPath) o; + return ObjectUtils.nullSafeEquals(properties, that.properties); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(properties); + } + /* * (non-Javadoc) * @see java.lang.Object#toString() diff --git a/src/main/java/org/springframework/data/mapping/context/PersistentPropertyPathFactory.java b/src/main/java/org/springframework/data/mapping/context/PersistentPropertyPathFactory.java index 1a657a0b1..ebca55677 100644 --- a/src/main/java/org/springframework/data/mapping/context/PersistentPropertyPathFactory.java +++ b/src/main/java/org/springframework/data/mapping/context/PersistentPropertyPathFactory.java @@ -15,22 +15,7 @@ */ package org.springframework.data.mapping.context; -import lombok.AccessLevel; -import lombok.RequiredArgsConstructor; -import lombok.ToString; -import lombok.Value; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -50,16 +35,16 @@ import org.springframework.data.util.TypeInformation; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ConcurrentReferenceHashMap; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** * A factory implementation to create {@link PersistentPropertyPath} instances in various ways. - * + * * @author Oliver Gierke * @since 2.1 * @soundtrack Cypress Hill - Boom Biddy Bye Bye (Fugees Remix, Unreleased & Revamped) */ -@RequiredArgsConstructor class PersistentPropertyPathFactory, P extends PersistentProperty

> { private static final Predicate>> IS_ENTITY = it -> it.isEntity(); @@ -67,9 +52,13 @@ class PersistentPropertyPathFactory, P extends private final Map> propertyPaths = new ConcurrentReferenceHashMap<>(); private final MappingContext context; + public PersistentPropertyPathFactory(MappingContext context) { + this.context = context; + } + /** * Creates a new {@link PersistentPropertyPath} for the given property path on the given type. - * + * * @param type must not be {@literal null}. * @param propertyPath must not be {@literal null}. * @return @@ -84,7 +73,7 @@ class PersistentPropertyPathFactory, P extends /** * Creates a new {@link PersistentPropertyPath} for the given property path on the given type. - * + * * @param type must not be {@literal null}. * @param propertyPath must not be {@literal null}. * @return @@ -99,7 +88,7 @@ class PersistentPropertyPathFactory, P extends /** * Creates a new {@link PersistentPropertyPath} for the given {@link PropertyPath}. - * + * * @param path must not be {@literal null}. * @return */ @@ -113,7 +102,7 @@ class PersistentPropertyPathFactory, P extends /** * Creates a new {@link PersistentPropertyPath} based on a given type and {@link Predicate} to select properties * matching it. - * + * * @param type must not be {@literal null}. * @param propertyFilter must not be {@literal null}. * @return @@ -129,7 +118,7 @@ class PersistentPropertyPathFactory, P extends /** * Creates a new {@link PersistentPropertyPath} based on a given type and {@link Predicate} to select properties * matching it. - * + * * @param type must not be {@literal null}. * @param propertyFilter must not be {@literal null}. * @param traversalGuard must not be {@literal null}. @@ -148,7 +137,7 @@ class PersistentPropertyPathFactory, P extends /** * Creates a new {@link PersistentPropertyPath} based on a given type and {@link Predicate} to select properties * matching it. - * + * * @param type must not be {@literal null}. * @param propertyFilter must not be {@literal null}. * @return @@ -160,7 +149,7 @@ class PersistentPropertyPathFactory, P extends /** * Creates a new {@link PersistentPropertyPath} based on a given type and {@link Predicate} to select properties * matching it. - * + * * @param type must not be {@literal null}. * @param propertyFilter must not be {@literal null}. * @param traversalGuard must not be {@literal null}. @@ -277,15 +266,73 @@ class PersistentPropertyPathFactory, P extends return properties; } - @Value(staticConstructor = "of") - static class TypeAndPath { + static final class TypeAndPath { - TypeInformation type; - String path; + private final TypeInformation type; + private final String path; + + private TypeAndPath(TypeInformation type, String path) { + this.type = type; + this.path = path; + } + + public static TypeAndPath of(TypeInformation type, String path) { + return new TypeAndPath(type, path); + } + + public TypeInformation getType() { + return this.type; + } + + public String getPath() { + return this.path; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof TypeAndPath)) { + return false; + } + + TypeAndPath that = (TypeAndPath) o; + + if (!ObjectUtils.nullSafeEquals(type, that.type)) { + return false; + } + + return ObjectUtils.nullSafeEquals(path, that.path); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(type); + result = 31 * result + ObjectUtils.nullSafeHashCode(path); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "PersistentPropertyPathFactory.TypeAndPath(type=" + this.getType() + ", path=" + this.getPath() + ")"; + } } - @ToString - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) static class DefaultPersistentPropertyPaths> implements PersistentPropertyPaths { @@ -295,9 +342,14 @@ class PersistentPropertyPathFactory, P extends private final TypeInformation type; private final Iterable> paths; + private DefaultPersistentPropertyPaths(TypeInformation type, Iterable> paths) { + this.type = type; + this.paths = paths; + } + /** * Creates a new {@link DefaultPersistentPropertyPaths} instance - * + * * @param type * @param paths * @return @@ -312,7 +364,7 @@ class PersistentPropertyPathFactory, P extends return new DefaultPersistentPropertyPaths<>(type, sorted); } - /* + /* * (non-Javadoc) * @see org.springframework.data.mapping.PersistentPropertyPaths#getFirst() */ @@ -321,7 +373,7 @@ class PersistentPropertyPathFactory, P extends return isEmpty() ? Optional.empty() : Optional.of(iterator().next()); } - /* + /* * (non-Javadoc) * @see org.springframework.data.mapping.PersistentPropertyPaths#contains(java.lang.String) */ @@ -330,7 +382,7 @@ class PersistentPropertyPathFactory, P extends return contains(PropertyPath.from(path, type)); } - /* + /* * (non-Javadoc) * @see org.springframework.data.mapping.PersistentPropertyPaths#contains(org.springframework.data.mapping.PropertyPath) */ @@ -348,7 +400,7 @@ class PersistentPropertyPathFactory, P extends return stream().anyMatch(it -> dotPath.equals(it.toDotPath())); } - /* + /* * (non-Javadoc) * @see java.lang.Iterable#iterator() */ @@ -373,14 +425,24 @@ class PersistentPropertyPathFactory, P extends return paths.equals(this.paths) ? this : new DefaultPersistentPropertyPaths<>(type, paths); } + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "PersistentPropertyPathFactory.DefaultPersistentPropertyPaths(type=" + this.type + ", paths=" + this.paths + + ")"; + } + /** * Simple {@link Comparator} to sort {@link PersistentPropertyPath} instances by their property segment's name * length. - * + * * @author Oliver Gierke * @since 2.1 */ - private static enum ShortestSegmentFirst + private enum ShortestSegmentFirst implements Comparator>> { INSTANCE; diff --git a/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java b/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java index e123ed8ed..9fcff6c24 100644 --- a/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java +++ b/src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java @@ -15,9 +15,6 @@ */ package org.springframework.data.mapping.model; -import lombok.AccessLevel; -import lombok.Getter; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -55,18 +52,18 @@ public abstract class AbstractPersistentProperty

private final TypeInformation information; private final Class rawType; private final Lazy> association; - private final @Getter PersistentEntity owner; + private final PersistentEntity owner; @SuppressWarnings("null") // - private final @Getter(value = AccessLevel.PROTECTED, onMethod = @__(@SuppressWarnings("null"))) Property property; + private final Property property; private final Lazy hashCode; private final Lazy usePropertyAccess; private final Lazy>> entityTypeInformation; - private final @Getter(onMethod = @__(@Nullable)) Method getter; - private final @Getter(onMethod = @__(@Nullable)) Method setter; - private final @Getter(onMethod = @__(@Nullable)) Field field; - private final @Getter(onMethod = @__(@Nullable)) Method wither; + private final Method getter; + private final Method setter; + private final Field field; + private final Method wither; private final boolean immutable; public AbstractPersistentProperty(Property property, PersistentEntity owner, @@ -104,6 +101,15 @@ public abstract class AbstractPersistentProperty

protected abstract Association

createAssociation(); + /* + * (non-Javadoc) + * @see org.springframework.data.mapping.PersistentProperty#getOwner() + */ + @Override + public PersistentEntity getOwner() { + return this.owner; + } + /* * (non-Javadoc) * @see org.springframework.data.mapping.PersistentProperty#getName() @@ -156,6 +162,42 @@ public abstract class AbstractPersistentProperty

.orElseGet(Collections::emptySet); } + /* + * (non-Javadoc) + * @see org.springframework.data.mapping.PersistentProperty#getGetter() + */ + @Override + public Method getGetter() { + return this.getter; + } + + /* + * (non-Javadoc) + * @see org.springframework.data.mapping.PersistentProperty#getSetter() + */ + @Override + public Method getSetter() { + return this.setter; + } + + /* + * (non-Javadoc) + * @see org.springframework.data.mapping.PersistentProperty#getWither() + */ + @Override + public Method getWither() { + return this.wither; + } + + /* + * (non-Javadoc) + * @see org.springframework.data.mapping.PersistentProperty#getField() + */ + @Nullable + public Field getField() { + return this.field; + } + /* * (non-Javadoc) * @see org.springframework.data.mapping.PersistentProperty#getSpelExpression() @@ -294,6 +336,11 @@ public abstract class AbstractPersistentProperty

return usePropertyAccess.get(); } + @SuppressWarnings("null") + protected Property getProperty() { + return this.property; + } + /* * (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) diff --git a/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java b/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java index 2c48ed39a..308d3d053 100644 --- a/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java +++ b/src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java @@ -15,12 +15,18 @@ */ package org.springframework.data.mapping.model; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.io.Serializable; import java.lang.annotation.Annotation; -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.TreeSet; import java.util.stream.Collectors; import org.springframework.core.annotation.AnnotatedElementUtils; @@ -453,7 +459,7 @@ public class BasicPersistentEntity> implement return propertyAccessorFactory.getPropertyAccessor(this, bean); } - /* + /* * (non-Javadoc) * @see org.springframework.data.mapping.PersistentEntity#getPropertyPathAccessor(java.lang.Object) */ @@ -552,7 +558,7 @@ public class BasicPersistentEntity> implement * * @param bean must not be {@literal null}. */ - private final void verifyBeanType(Object bean) { + private void verifyBeanType(Object bean) { Assert.notNull(bean, "Target bean must not be null!"); Assert.isInstanceOf(getType(), bean, @@ -603,12 +609,15 @@ public class BasicPersistentEntity> implement * * @author Oliver Gierke */ - @RequiredArgsConstructor private static final class AssociationComparator

> implements Comparator>, Serializable { private static final long serialVersionUID = 4508054194886854513L; - private final @NonNull Comparator

delegate; + private final Comparator

delegate; + + AssociationComparator(Comparator

delegate) { + this.delegate = delegate; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/mapping/model/BytecodeUtil.java b/src/main/java/org/springframework/data/mapping/model/BytecodeUtil.java index bfc386f65..3ef3f8810 100644 --- a/src/main/java/org/springframework/data/mapping/model/BytecodeUtil.java +++ b/src/main/java/org/springframework/data/mapping/model/BytecodeUtil.java @@ -17,8 +17,6 @@ package org.springframework.data.mapping.model; import static org.springframework.asm.Opcodes.*; -import lombok.experimental.UtilityClass; - import java.lang.reflect.Modifier; import org.springframework.asm.MethodVisitor; @@ -31,8 +29,9 @@ import org.springframework.asm.Type; * @author Mark Paluch * @since 2.1 */ -@UtilityClass -class BytecodeUtil { +abstract class BytecodeUtil { + + private BytecodeUtil() {} /** * Returns the appropriate autoboxing type. diff --git a/src/main/java/org/springframework/data/mapping/model/ClassGeneratingPropertyAccessorFactory.java b/src/main/java/org/springframework/data/mapping/model/ClassGeneratingPropertyAccessorFactory.java index 984441ee4..a7563915e 100644 --- a/src/main/java/org/springframework/data/mapping/model/ClassGeneratingPropertyAccessorFactory.java +++ b/src/main/java/org/springframework/data/mapping/model/ClassGeneratingPropertyAccessorFactory.java @@ -18,9 +18,6 @@ package org.springframework.data.mapping.model; import static org.springframework.asm.Opcodes.*; import static org.springframework.data.mapping.model.BytecodeUtil.*; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; @@ -1397,12 +1394,16 @@ public class ClassGeneratingPropertyAccessorFactory implements PersistentPropert * * @author Mark Paluch */ - @RequiredArgsConstructor static class PropertyStackAddress implements Comparable { - private final @NonNull Label label; + private final Label label; private final int hash; + public PropertyStackAddress(Label label, int hash) { + this.label = label; + this.hash = hash; + } + /* * (non-Javadoc) * @see java.lang.Comparable#compareTo(java.lang.Object) diff --git a/src/main/java/org/springframework/data/mapping/model/DefaultSpELExpressionEvaluator.java b/src/main/java/org/springframework/data/mapping/model/DefaultSpELExpressionEvaluator.java index 9b0601f60..d0131b376 100644 --- a/src/main/java/org/springframework/data/mapping/model/DefaultSpELExpressionEvaluator.java +++ b/src/main/java/org/springframework/data/mapping/model/DefaultSpELExpressionEvaluator.java @@ -16,14 +16,12 @@ package org.springframework.data.mapping.model; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.data.mapping.PreferredConstructor.Parameter; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.lang.Nullable; +import org.springframework.util.Assert; /** * {@link ParameterValueProvider} implementation that evaluates the {@link Parameter}s key against @@ -31,11 +29,19 @@ import org.springframework.lang.Nullable; * * @author Oliver Gierke */ -@RequiredArgsConstructor public class DefaultSpELExpressionEvaluator implements SpELExpressionEvaluator { - private final @NonNull Object source; - private final @NonNull SpELContext factory; + private final Object source; + private final SpELContext factory; + + public DefaultSpELExpressionEvaluator(Object source, SpELContext factory) { + + Assert.notNull(source, "Source must not be null!"); + Assert.notNull(factory, "SpELContext must not be null!"); + + this.source = source; + this.factory = factory; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/mapping/model/InstantiationAwarePropertyAccessorFactory.java b/src/main/java/org/springframework/data/mapping/model/InstantiationAwarePropertyAccessorFactory.java index 56011c86d..29dbb1820 100644 --- a/src/main/java/org/springframework/data/mapping/model/InstantiationAwarePropertyAccessorFactory.java +++ b/src/main/java/org/springframework/data/mapping/model/InstantiationAwarePropertyAccessorFactory.java @@ -15,8 +15,6 @@ */ package org.springframework.data.mapping.model; -import lombok.RequiredArgsConstructor; - import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentPropertyAccessor; @@ -26,12 +24,17 @@ import org.springframework.data.mapping.PersistentPropertyAccessor; * * @author Oliver Drotbohm */ -@RequiredArgsConstructor public class InstantiationAwarePropertyAccessorFactory implements PersistentPropertyAccessorFactory { private final PersistentPropertyAccessorFactory delegate; private final EntityInstantiators instantiators; + public InstantiationAwarePropertyAccessorFactory(PersistentPropertyAccessorFactory delegate, + EntityInstantiators instantiators) { + this.delegate = delegate; + this.instantiators = instantiators; + } + /* * (non-Javadoc) * @see org.springframework.data.mapping.model.PersistentPropertyAccessorFactory#getPropertyAccessor(org.springframework.data.mapping.PersistentEntity, java.lang.Object) diff --git a/src/main/java/org/springframework/data/mapping/model/KotlinCopyMethod.java b/src/main/java/org/springframework/data/mapping/model/KotlinCopyMethod.java index d3b10e80d..d476e1f69 100644 --- a/src/main/java/org/springframework/data/mapping/model/KotlinCopyMethod.java +++ b/src/main/java/org/springframework/data/mapping/model/KotlinCopyMethod.java @@ -22,7 +22,6 @@ import kotlin.reflect.KParameter; import kotlin.reflect.KParameter.Kind; import kotlin.reflect.full.KClasses; import kotlin.reflect.jvm.ReflectJvmMapping; -import lombok.Getter; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -43,7 +42,6 @@ import org.springframework.util.Assert; * @author Mark Paluch * @since 2.1 */ -@Getter class KotlinCopyMethod { private final Method publicCopyMethod; @@ -86,6 +84,22 @@ class KotlinCopyMethod { return publicCopyMethod.map(method -> new KotlinCopyMethod(method, syntheticCopyMethod.get())); } + public Method getPublicCopyMethod() { + return this.publicCopyMethod; + } + + public Method getSyntheticCopyMethod() { + return this.syntheticCopyMethod; + } + + public int getParameterCount() { + return this.parameterCount; + } + + public KFunction getCopyFunction() { + return this.copyFunction; + } + /** * Check whether the {@link PersistentProperty} is accepted as part of the copy method. * @@ -219,7 +233,6 @@ class KotlinCopyMethod { * * @author Mark Paluch */ - @Getter static class KotlinCopyByProperty { private final int parameterPosition; @@ -243,5 +256,17 @@ class KotlinCopyMethod { return -1; } + + public int getParameterPosition() { + return this.parameterPosition; + } + + public int getParameterCount() { + return this.parameterCount; + } + + public KotlinDefaultMask getDefaultMask() { + return this.defaultMask; + } } } diff --git a/src/main/java/org/springframework/data/mapping/model/KotlinDefaultMask.java b/src/main/java/org/springframework/data/mapping/model/KotlinDefaultMask.java index fff593070..89c191579 100644 --- a/src/main/java/org/springframework/data/mapping/model/KotlinDefaultMask.java +++ b/src/main/java/org/springframework/data/mapping/model/KotlinDefaultMask.java @@ -18,9 +18,6 @@ package org.springframework.data.mapping.model; import kotlin.reflect.KFunction; import kotlin.reflect.KParameter; import kotlin.reflect.KParameter.Kind; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; import java.util.ArrayList; import java.util.List; @@ -33,12 +30,14 @@ import java.util.function.Predicate; * @author Mark Paluch * @since 2.1 */ -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) public class KotlinDefaultMask { - @Getter private final int[] defaulting; + private KotlinDefaultMask(int[] defaulting) { + this.defaulting = defaulting; + } + /** * Callback method to notify {@link IntConsumer} for each defaulting mask. * @@ -97,4 +96,8 @@ public class KotlinDefaultMask { return new KotlinDefaultMask(masks.stream().mapToInt(i -> i).toArray()); } + + public int[] getDefaulting() { + return this.defaulting; + } } diff --git a/src/main/java/org/springframework/data/mapping/model/PersistentEntityParameterValueProvider.java b/src/main/java/org/springframework/data/mapping/model/PersistentEntityParameterValueProvider.java index 9c4762473..b0789a218 100644 --- a/src/main/java/org/springframework/data/mapping/model/PersistentEntityParameterValueProvider.java +++ b/src/main/java/org/springframework/data/mapping/model/PersistentEntityParameterValueProvider.java @@ -15,9 +15,6 @@ */ package org.springframework.data.mapping.model; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.data.mapping.MappingException; import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentProperty; @@ -33,14 +30,20 @@ import org.springframework.lang.Nullable; * * @author Oliver Gierke */ -@RequiredArgsConstructor public class PersistentEntityParameterValueProvider

> implements ParameterValueProvider

{ - private final @NonNull PersistentEntity entity; - private final @NonNull PropertyValueProvider

provider; + private final PersistentEntity entity; + private final PropertyValueProvider

provider; private final @Nullable Object parent; + public PersistentEntityParameterValueProvider(PersistentEntity entity, PropertyValueProvider

provider, + Object parent) { + this.entity = entity; + this.provider = provider; + this.parent = parent; + } + /* * (non-Javadoc) * @see org.springframework.data.mapping.model.ParameterValueProvider#getParameterValue(org.springframework.data.mapping.PreferredConstructor.Parameter) diff --git a/src/main/java/org/springframework/data/mapping/model/Property.java b/src/main/java/org/springframework/data/mapping/model/Property.java index ea253d7b3..fcce08e82 100644 --- a/src/main/java/org/springframework/data/mapping/model/Property.java +++ b/src/main/java/org/springframework/data/mapping/model/Property.java @@ -15,8 +15,6 @@ */ package org.springframework.data.mapping.model; -import lombok.Getter; - import java.beans.FeatureDescriptor; import java.beans.PropertyDescriptor; import java.lang.reflect.Field; @@ -42,7 +40,7 @@ import org.springframework.util.StringUtils; */ public class Property { - private final @Getter Optional field; + private final Optional field; private final Optional descriptor; private final Class rawType; @@ -178,6 +176,15 @@ public class Property { return wither.get(); } + /** + * Returns the field of the property if available and if its first (only) parameter matches the type of the property. + * + * @return will never be {@literal null}. + */ + public Optional getField() { + return this.field; + } + /** * Returns whether the property exposes a getter or a setter. * diff --git a/src/main/java/org/springframework/data/mapping/model/SimplePersistentPropertyPathAccessor.java b/src/main/java/org/springframework/data/mapping/model/SimplePersistentPropertyPathAccessor.java index c8e685941..6c7029d0f 100644 --- a/src/main/java/org/springframework/data/mapping/model/SimplePersistentPropertyPathAccessor.java +++ b/src/main/java/org/springframework/data/mapping/model/SimplePersistentPropertyPathAccessor.java @@ -17,15 +17,13 @@ package org.springframework.data.mapping.model; import static org.springframework.data.mapping.AccessOptions.SetOptions.SetNulls.*; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - import java.util.Collection; import java.util.Map; import java.util.Map.Entry; import java.util.stream.Collectors; +import org.slf4j.Logger; + import org.springframework.core.CollectionFactory; import org.springframework.data.mapping.AccessOptions; import org.springframework.data.mapping.AccessOptions.GetOptions; @@ -49,11 +47,15 @@ import org.springframework.util.Assert; * @since 2.3 * @soundtrack Ron Spielman - Nineth Song (Tip of My Tongue) */ -@Slf4j -@RequiredArgsConstructor class SimplePersistentPropertyPathAccessor implements PersistentPropertyPathAccessor { - private final @NonNull PersistentPropertyAccessor delegate; + private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SimplePersistentPropertyPathAccessor.class); + + private final PersistentPropertyAccessor delegate; + + public SimplePersistentPropertyPathAccessor(PersistentPropertyAccessor delegate) { + this.delegate = delegate; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/mapping/model/SpELExpressionParameterValueProvider.java b/src/main/java/org/springframework/data/mapping/model/SpELExpressionParameterValueProvider.java index f66a5d6af..a35625cd1 100644 --- a/src/main/java/org/springframework/data/mapping/model/SpELExpressionParameterValueProvider.java +++ b/src/main/java/org/springframework/data/mapping/model/SpELExpressionParameterValueProvider.java @@ -15,9 +15,6 @@ */ package org.springframework.data.mapping.model; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.core.convert.ConversionService; import org.springframework.data.mapping.PersistentProperty; import org.springframework.data.mapping.PreferredConstructor.Parameter; @@ -30,13 +27,20 @@ import org.springframework.lang.Nullable; * @author Oliver Gierke * @author Mark Paluch */ -@RequiredArgsConstructor public class SpELExpressionParameterValueProvider

> implements ParameterValueProvider

{ - private final @NonNull SpELExpressionEvaluator evaluator; - private final @NonNull ConversionService conversionService; - private final @NonNull ParameterValueProvider

delegate; + private final SpELExpressionEvaluator evaluator; + private final ConversionService conversionService; + private final ParameterValueProvider

delegate; + + public SpELExpressionParameterValueProvider(SpELExpressionEvaluator evaluator, ConversionService conversionService, + ParameterValueProvider

delegate) { + + this.evaluator = evaluator; + this.conversionService = conversionService; + this.delegate = delegate; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/projection/DefaultProjectionInformation.java b/src/main/java/org/springframework/data/projection/DefaultProjectionInformation.java index c28687441..22a037991 100644 --- a/src/main/java/org/springframework/data/projection/DefaultProjectionInformation.java +++ b/src/main/java/org/springframework/data/projection/DefaultProjectionInformation.java @@ -15,8 +15,6 @@ */ package org.springframework.data.projection; -import lombok.extern.slf4j.Slf4j; - import java.beans.PropertyDescriptor; import java.io.IOException; import java.lang.reflect.Method; @@ -29,6 +27,8 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; +import org.slf4j.Logger; + import org.springframework.beans.BeanUtils; import org.springframework.core.type.MethodMetadata; import org.springframework.data.type.MethodsMetadata; @@ -128,9 +128,10 @@ class DefaultProjectionInformation implements ProjectionInformation { * @since 2.1 * @soundtrack The Meters - Cissy Strut (Here Comes The Meter Man) */ - @Slf4j private static class PropertyDescriptorSource { + private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(PropertyDescriptorSource.class); + private final Class type; private final Optional metadata; diff --git a/src/main/java/org/springframework/data/projection/MapAccessingMethodInterceptor.java b/src/main/java/org/springframework/data/projection/MapAccessingMethodInterceptor.java index 4ffbc7d44..66d265d18 100644 --- a/src/main/java/org/springframework/data/projection/MapAccessingMethodInterceptor.java +++ b/src/main/java/org/springframework/data/projection/MapAccessingMethodInterceptor.java @@ -15,9 +15,6 @@ */ package org.springframework.data.projection; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.lang.reflect.Method; import java.util.Map; @@ -25,6 +22,8 @@ import javax.annotation.Nullable; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; + +import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; /** @@ -33,10 +32,16 @@ import org.springframework.util.ReflectionUtils; * @author Oliver Gierke * @since 1.10 */ -@RequiredArgsConstructor class MapAccessingMethodInterceptor implements MethodInterceptor { - private final @NonNull Map map; + private final Map map; + + MapAccessingMethodInterceptor(Map map) { + + Assert.notNull(map, "Map must not be null"); + + this.map = map; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/projection/ProjectingMethodInterceptor.java b/src/main/java/org/springframework/data/projection/ProjectingMethodInterceptor.java index 519453d71..655087969 100644 --- a/src/main/java/org/springframework/data/projection/ProjectingMethodInterceptor.java +++ b/src/main/java/org/springframework/data/projection/ProjectingMethodInterceptor.java @@ -15,9 +15,6 @@ */ package org.springframework.data.projection; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.lang.reflect.Array; import java.util.Arrays; import java.util.Collection; @@ -30,6 +27,7 @@ import javax.annotation.Nonnull; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; + import org.springframework.core.CollectionFactory; import org.springframework.core.convert.ConversionService; import org.springframework.data.util.ClassTypeInformation; @@ -47,12 +45,19 @@ import org.springframework.util.ObjectUtils; * @author Mark Paluch * @since 1.10 */ -@RequiredArgsConstructor class ProjectingMethodInterceptor implements MethodInterceptor { - private final @NonNull ProjectionFactory factory; - private final @NonNull MethodInterceptor delegate; - private final @NonNull ConversionService conversionService; + private final ProjectionFactory factory; + private final MethodInterceptor delegate; + private final ConversionService conversionService; + + ProjectingMethodInterceptor(ProjectionFactory factory, MethodInterceptor delegate, + ConversionService conversionService) { + + this.factory = factory; + this.delegate = delegate; + this.conversionService = conversionService; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/projection/SpelEvaluatingMethodInterceptor.java b/src/main/java/org/springframework/data/projection/SpelEvaluatingMethodInterceptor.java index 344c57207..7976bf9bd 100644 --- a/src/main/java/org/springframework/data/projection/SpelEvaluatingMethodInterceptor.java +++ b/src/main/java/org/springframework/data/projection/SpelEvaluatingMethodInterceptor.java @@ -22,6 +22,7 @@ import java.util.Map; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; + import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.expression.BeanFactoryResolver; @@ -34,6 +35,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** @@ -144,10 +146,71 @@ class SpelEvaluatingMethodInterceptor implements MethodInterceptor { * * @author Oliver Gierke */ - @lombok.Value(staticConstructor = "of") - static class TargetWrapper { + static final class TargetWrapper { - Object target; - Object[] args; + private final Object target; + private final Object[] args; + + private TargetWrapper(Object target, Object[] args) { + this.target = target; + this.args = args; + } + + public static TargetWrapper of(Object target, Object[] args) { + return new TargetWrapper(target, args); + } + + public Object getTarget() { + return this.target; + } + + public Object[] getArgs() { + return this.args; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof TargetWrapper)) { + return false; + } + + TargetWrapper that = (TargetWrapper) o; + + if (!ObjectUtils.nullSafeEquals(target, that.target)) { + return false; + } + + return ObjectUtils.nullSafeEquals(args, that.args); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(target); + result = 31 * result + ObjectUtils.nullSafeHashCode(args); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "SpelEvaluatingMethodInterceptor.TargetWrapper(target=" + this.getTarget() + ", args=" + + java.util.Arrays.deepToString(this.getArgs()) + ")"; + } } } diff --git a/src/main/java/org/springframework/data/querydsl/QuerydslUtils.java b/src/main/java/org/springframework/data/querydsl/QuerydslUtils.java index 2d188200f..e027376c5 100644 --- a/src/main/java/org/springframework/data/querydsl/QuerydslUtils.java +++ b/src/main/java/org/springframework/data/querydsl/QuerydslUtils.java @@ -15,8 +15,6 @@ */ package org.springframework.data.querydsl; -import lombok.experimental.UtilityClass; - import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; @@ -29,12 +27,13 @@ import com.querydsl.core.types.PathType; * * @author Oliver Gierke */ -@UtilityClass -public class QuerydslUtils { +public abstract class QuerydslUtils { public static final boolean QUERY_DSL_PRESENT = org.springframework.util.ClassUtils .isPresent("com.querydsl.core.types.Predicate", QuerydslUtils.class.getClassLoader()); + private QuerydslUtils() {} + /** * Returns the property path for the given {@link Path}. * diff --git a/src/main/java/org/springframework/data/querydsl/binding/PropertyPathInformation.java b/src/main/java/org/springframework/data/querydsl/binding/PropertyPathInformation.java index 396a2cc8c..a45eff66f 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/PropertyPathInformation.java +++ b/src/main/java/org/springframework/data/querydsl/binding/PropertyPathInformation.java @@ -15,11 +15,6 @@ */ package org.springframework.data.querydsl.binding; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; -import lombok.ToString; - import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.util.Optional; @@ -29,6 +24,7 @@ import org.springframework.data.mapping.PropertyPath; import org.springframework.data.querydsl.EntityPathResolver; import org.springframework.data.util.TypeInformation; import org.springframework.lang.Nullable; +import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; import com.querydsl.core.types.Path; @@ -41,13 +37,14 @@ import com.querydsl.core.types.dsl.CollectionPathBase; * @author Christoph Strobl * @since 1.13 */ -@ToString -@EqualsAndHashCode -@RequiredArgsConstructor(staticName = "of", access = AccessLevel.PRIVATE) class PropertyPathInformation implements PathInformation { private final PropertyPath path; + private PropertyPathInformation(PropertyPath path) { + this.path = path; + } + /** * Creates a new {@link PropertyPathInformation} for the given path and type. * @@ -70,6 +67,10 @@ class PropertyPathInformation implements PathInformation { return PropertyPathInformation.of(PropertyPath.from(path, type)); } + private static PropertyPathInformation of(PropertyPath path) { + return new PropertyPathInformation(path); + } + /* * (non-Javadoc) * @see org.springframework.data.querydsl.binding.PathInformation#getLeafType() @@ -149,4 +150,41 @@ class PropertyPathInformation implements PathInformation { return (Path) value; }); } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof PropertyPathInformation)) { + return false; + } + + PropertyPathInformation that = (PropertyPathInformation) o; + return ObjectUtils.nullSafeEquals(path, that.path); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(path); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "PropertyPathInformation(path=" + this.path + ")"; + } } diff --git a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindings.java b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindings.java index 6af83926c..824c9ae09 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindings.java +++ b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindings.java @@ -15,10 +15,6 @@ */ package org.springframework.data.querydsl.binding; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.Value; - import java.util.Arrays; import java.util.HashSet; import java.util.LinkedHashMap; @@ -34,6 +30,7 @@ import org.springframework.data.util.Optionals; import org.springframework.data.util.TypeInformation; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import com.querydsl.core.types.Path; @@ -469,10 +466,13 @@ public class QuerydslBindings { * * @author Oliver Gierke */ - @RequiredArgsConstructor public final class TypeBinder { - private final @NonNull Class type; + private final Class type; + + public TypeBinder(Class type) { + this.type = type; + } /** * Configures the given {@link SingleValueBinding} to be used for the current type. @@ -511,11 +511,15 @@ public class QuerydslBindings { * @author Oliver Gierke * @since 1.11 */ - @Value - private static class PathAndBinding

, T> { + private static final class PathAndBinding

, T> { - @NonNull Optional> path; - @NonNull Optional> binding; + private final Optional> path; + private final Optional> binding; + + PathAndBinding(Optional> path, Optional> binding) { + this.path = path; + this.binding = binding; + } public static > PathAndBinding withPath(P path) { return new PathAndBinding<>(Optional.of(path), Optional.empty()); @@ -528,5 +532,52 @@ public class QuerydslBindings { public PathAndBinding with(MultiValueBinding binding) { return new PathAndBinding<>(path, Optional.of(binding)); } + + public Optional> getPath() { + return this.path; + } + + public Optional> getBinding() { + return this.binding; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof PathAndBinding)) { + return false; + } + PathAndBinding that = (PathAndBinding) o; + if (!ObjectUtils.nullSafeEquals(path, that.path)) { + return false; + } + return ObjectUtils.nullSafeEquals(binding, that.binding); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(path); + result = 31 * result + ObjectUtils.nullSafeHashCode(binding); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "QuerydslBindings.PathAndBinding(path=" + this.getPath() + ", binding=" + this.getBinding() + ")"; + } } } diff --git a/src/main/java/org/springframework/data/querydsl/binding/QuerydslPathInformation.java b/src/main/java/org/springframework/data/querydsl/binding/QuerydslPathInformation.java index d1aa5d70f..6c711983e 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/QuerydslPathInformation.java +++ b/src/main/java/org/springframework/data/querydsl/binding/QuerydslPathInformation.java @@ -15,16 +15,13 @@ */ package org.springframework.data.querydsl.binding; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; -import lombok.ToString; - import java.beans.PropertyDescriptor; import org.springframework.beans.BeanUtils; import org.springframework.data.querydsl.EntityPathResolver; import org.springframework.data.querydsl.QuerydslUtils; import org.springframework.lang.Nullable; +import org.springframework.util.ObjectUtils; import com.querydsl.core.types.Path; @@ -34,13 +31,18 @@ import com.querydsl.core.types.Path; * @author Oliver Gierke * @since 1.13 */ -@ToString -@EqualsAndHashCode -@RequiredArgsConstructor(staticName = "of") class QuerydslPathInformation implements PathInformation { private final Path path; + private QuerydslPathInformation(Path path) { + this.path = path; + } + + public static QuerydslPathInformation of(Path path) { + return new QuerydslPathInformation(path); + } + /* * (non-Javadoc) * @see org.springframework.data.querydsl.binding.MappedPath#getLeafType() @@ -101,4 +103,41 @@ class QuerydslPathInformation implements PathInformation { public Path reifyPath(EntityPathResolver resolver) { return path; } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof QuerydslPathInformation)) { + return false; + } + + QuerydslPathInformation that = (QuerydslPathInformation) o; + return ObjectUtils.nullSafeEquals(path, that.path); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(path); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "QuerydslPathInformation(path=" + this.path + ")"; + } } diff --git a/src/main/java/org/springframework/data/repository/cdi/CdiRepositoryContext.java b/src/main/java/org/springframework/data/repository/cdi/CdiRepositoryContext.java index f9d95148b..9561902dc 100644 --- a/src/main/java/org/springframework/data/repository/cdi/CdiRepositoryContext.java +++ b/src/main/java/org/springframework/data/repository/cdi/CdiRepositoryContext.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.cdi; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - import java.util.Optional; import java.util.stream.Stream; @@ -45,7 +42,7 @@ import org.springframework.util.ClassUtils; * Context for CDI repositories. This class provides {@link ClassLoader} and * {@link org.springframework.data.repository.core.support.RepositoryFragment detection} which are commonly used within * CDI. - * + * * @author Mark Paluch * @since 2.1 */ @@ -59,7 +56,7 @@ public class CdiRepositoryContext { /** * Create a new {@link CdiRepositoryContext} given {@link ClassLoader} and initialize * {@link CachingMetadataReaderFactory}. - * + * * @param classLoader must not be {@literal null}. */ public CdiRepositoryContext(ClassLoader classLoader) { @@ -70,7 +67,7 @@ public class CdiRepositoryContext { /** * Create a new {@link CdiRepositoryContext} given {@link ClassLoader} and * {@link CustomRepositoryImplementationDetector}. - * + * * @param classLoader must not be {@literal null}. * @param detector must not be {@literal null}. */ @@ -93,7 +90,7 @@ public class CdiRepositoryContext { /** * Load a {@link Class} using the CDI {@link ClassLoader}. - * + * * @param className * @return * @throws UnsatisfiedResolutionException if the class cannot be found. @@ -109,7 +106,7 @@ public class CdiRepositoryContext { /** * Discover {@link RepositoryFragmentConfiguration fragment configurations} for a {@link Class repository interface}. - * + * * @param configuration must not be {@literal null}. * @param repositoryInterface must not be {@literal null}. * @return {@link Stream} of {@link RepositoryFragmentConfiguration fragment configurations}. @@ -162,13 +159,19 @@ public class CdiRepositoryContext { return beanClassName == null ? null : loadClass(beanClassName); } - @RequiredArgsConstructor private static class CdiImplementationDetectionConfiguration implements ImplementationDetectionConfiguration { private final CdiRepositoryConfiguration configuration; - private final @Getter MetadataReaderFactory metadataReaderFactory; + private final MetadataReaderFactory metadataReaderFactory; - /* + CdiImplementationDetectionConfiguration(CdiRepositoryConfiguration configuration, + MetadataReaderFactory metadataReaderFactory) { + + this.configuration = configuration; + this.metadataReaderFactory = metadataReaderFactory; + } + + /* * (non-Javadoc) * @see org.springframework.data.repository.config.CustomRepositoryImplementationDetector.ImplementationDetectionConfiguration#getImplementationPostfix() */ @@ -177,7 +180,7 @@ public class CdiRepositoryContext { return configuration.getRepositoryImplementationPostfix(); } - /* + /* * (non-Javadoc) * @see org.springframework.data.repository.config.CustomRepositoryImplementationDetector.ImplementationDetectionConfiguration#getBasePackages() */ @@ -186,7 +189,7 @@ public class CdiRepositoryContext { return Streamable.empty(); } - /* + /* * (non-Javadoc) * @see org.springframework.data.repository.config.CustomRepositoryImplementationDetector.ImplementationDetectionConfiguration#getExcludeFilters() */ @@ -194,5 +197,9 @@ public class CdiRepositoryContext { public Streamable getExcludeFilters() { return Streamable.empty(); } + + public MetadataReaderFactory getMetadataReaderFactory() { + return this.metadataReaderFactory; + } } } diff --git a/src/main/java/org/springframework/data/repository/config/DefaultRepositoryConfiguration.java b/src/main/java/org/springframework/data/repository/config/DefaultRepositoryConfiguration.java index 08ded03db..17d3d5bfd 100644 --- a/src/main/java/org/springframework/data/repository/config/DefaultRepositoryConfiguration.java +++ b/src/main/java/org/springframework/data/repository/config/DefaultRepositoryConfiguration.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.config; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.util.Optional; import org.springframework.beans.factory.config.BeanDefinition; @@ -38,16 +35,23 @@ import org.springframework.util.StringUtils; * @author Jens Schauder * @author Mark Paluch */ -@RequiredArgsConstructor public class DefaultRepositoryConfiguration implements RepositoryConfiguration { public static final String DEFAULT_REPOSITORY_IMPLEMENTATION_POSTFIX = "Impl"; public static final Key DEFAULT_QUERY_LOOKUP_STRATEGY = Key.CREATE_IF_NOT_FOUND; - private final @NonNull T configurationSource; - private final @NonNull BeanDefinition definition; - private final @NonNull RepositoryConfigurationExtension extension; + private final T configurationSource; + private final BeanDefinition definition; + private final RepositoryConfigurationExtension extension; + + public DefaultRepositoryConfiguration(T configurationSource, BeanDefinition definition, + RepositoryConfigurationExtension extension) { + + this.configurationSource = configurationSource; + this.definition = definition; + this.extension = extension; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/repository/config/DeferredRepositoryInitializationListener.java b/src/main/java/org/springframework/data/repository/config/DeferredRepositoryInitializationListener.java index c42f3d879..9c771c901 100644 --- a/src/main/java/org/springframework/data/repository/config/DeferredRepositoryInitializationListener.java +++ b/src/main/java/org/springframework/data/repository/config/DeferredRepositoryInitializationListener.java @@ -15,9 +15,7 @@ */ package org.springframework.data.repository.config; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.context.ApplicationListener; @@ -28,18 +26,21 @@ import org.springframework.data.repository.Repository; /** * {@link ApplicationListener} to trigger the initialization of Spring Data repositories right before the application * context is started. - * + * * @author Oliver Gierke * @since 2.1 * @soundtrack Dave Matthews Band - Here On Out (Come Tomorrow) */ -@Slf4j -@RequiredArgsConstructor class DeferredRepositoryInitializationListener implements ApplicationListener, Ordered { - private final @NonNull ListableBeanFactory beanFactory; + private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(DeferredRepositoryInitializationListener.class); + private final ListableBeanFactory beanFactory; - /* + DeferredRepositoryInitializationListener(ListableBeanFactory beanFactory) { + this.beanFactory = beanFactory; + } + + /* * (non-Javadoc) * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) */ @@ -53,7 +54,7 @@ class DeferredRepositoryInitializationListener implements ApplicationListener> configurations; + public LazyRepositoryInjectionPointResolver(Map> configurations) { + this.configurations = configurations; + } + /** * Returns a new {@link LazyRepositoryInjectionPointResolver} that will have its configurations augmented with the * given ones. diff --git a/src/main/java/org/springframework/data/repository/config/RepositoryConfigurationSourceSupport.java b/src/main/java/org/springframework/data/repository/config/RepositoryConfigurationSourceSupport.java index bdc0ee695..1a82464ed 100644 --- a/src/main/java/org/springframework/data/repository/config/RepositoryConfigurationSourceSupport.java +++ b/src/main/java/org/springframework/data/repository/config/RepositoryConfigurationSourceSupport.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.config; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - import java.util.Collections; import org.springframework.beans.factory.config.BeanDefinition; @@ -132,11 +129,16 @@ public abstract class RepositoryConfigurationSourceSupport implements Repository return new SpringImplementationDetectionConfiguration(this, factory); } - @RequiredArgsConstructor private class SpringImplementationDetectionConfiguration implements ImplementationDetectionConfiguration { private final RepositoryConfigurationSource source; - private final @Getter MetadataReaderFactory metadataReaderFactory; + private final MetadataReaderFactory metadataReaderFactory; + + SpringImplementationDetectionConfiguration(RepositoryConfigurationSource source, + MetadataReaderFactory metadataReaderFactory) { + this.source = source; + this.metadataReaderFactory = metadataReaderFactory; + } /* * (non-Javadoc) @@ -174,5 +176,9 @@ public abstract class RepositoryConfigurationSourceSupport implements Repository public String generateBeanName(BeanDefinition definition) { return source.generateBeanName(definition); } + + public MetadataReaderFactory getMetadataReaderFactory() { + return this.metadataReaderFactory; + } } } diff --git a/src/main/java/org/springframework/data/repository/config/RepositoryFragmentConfiguration.java b/src/main/java/org/springframework/data/repository/config/RepositoryFragmentConfiguration.java index 7c21df77d..07d061282 100644 --- a/src/main/java/org/springframework/data/repository/config/RepositoryFragmentConfiguration.java +++ b/src/main/java/org/springframework/data/repository/config/RepositoryFragmentConfiguration.java @@ -15,8 +15,6 @@ */ package org.springframework.data.repository.config; -import lombok.Value; - import java.beans.Introspector; import java.util.Optional; @@ -24,6 +22,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.data.config.ConfigurationUtils; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; +import org.springframework.util.ObjectUtils; /** * Fragment configuration consisting of an interface name and the implementation class name. @@ -32,11 +31,10 @@ import org.springframework.util.ClassUtils; * @author Oliver Gierke * @since 2.0 */ -@Value -public class RepositoryFragmentConfiguration { +public final class RepositoryFragmentConfiguration { - String interfaceName, className; - Optional beanDefinition; + private final String interfaceName, className; + private final Optional beanDefinition; /** * Creates a {@link RepositoryFragmentConfiguration} given {@code interfaceName} and {@code className} of the @@ -72,6 +70,13 @@ public class RepositoryFragmentConfiguration { this.beanDefinition = Optional.of(beanDefinition); } + public RepositoryFragmentConfiguration(String interfaceName, String className, + Optional beanDefinition) { + this.interfaceName = interfaceName; + this.className = className; + this.beanDefinition = beanDefinition; + } + /** * @return name of the implementation bean. */ @@ -85,4 +90,65 @@ public class RepositoryFragmentConfiguration { public String getFragmentBeanName() { return getImplementationBeanName() + "Fragment"; } + + public String getInterfaceName() { + return this.interfaceName; + } + + public String getClassName() { + return this.className; + } + + public Optional getBeanDefinition() { + return this.beanDefinition; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof RepositoryFragmentConfiguration)) { + return false; + } + + RepositoryFragmentConfiguration that = (RepositoryFragmentConfiguration) o; + if (!ObjectUtils.nullSafeEquals(interfaceName, that.interfaceName)) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(className, that.className)) { + return false; + } + + return ObjectUtils.nullSafeEquals(beanDefinition, that.beanDefinition); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(interfaceName); + result = 31 * result + ObjectUtils.nullSafeHashCode(className); + result = 31 * result + ObjectUtils.nullSafeHashCode(beanDefinition); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "RepositoryFragmentConfiguration(interfaceName=" + this.getInterfaceName() + ", className=" + + this.getClassName() + ", beanDefinition=" + this.getBeanDefinition() + ")"; + } } diff --git a/src/main/java/org/springframework/data/repository/config/SelectionSet.java b/src/main/java/org/springframework/data/repository/config/SelectionSet.java index 932158875..76d15bc5e 100644 --- a/src/main/java/org/springframework/data/repository/config/SelectionSet.java +++ b/src/main/java/org/springframework/data/repository/config/SelectionSet.java @@ -15,8 +15,6 @@ */ package org.springframework.data.repository.config; -import lombok.RequiredArgsConstructor; - import java.util.Collection; import java.util.Optional; import java.util.function.Function; @@ -31,12 +29,16 @@ import java.util.stream.Collectors; * @author Oliver Gierke * @since 2.0 */ -@RequiredArgsConstructor(staticName = "of") class SelectionSet { private final Collection collection; private final Function, Optional> fallback; + private SelectionSet(Collection collection, Function, Optional> fallback) { + this.collection = collection; + this.fallback = fallback; + } + /** * creates a {@link SelectionSet} with a default fallback of {@literal null}, when no element is found and an * {@link IllegalStateException} when no element is found. @@ -45,6 +47,10 @@ class SelectionSet { return new SelectionSet<>(collection, defaultFallback()); } + public static SelectionSet of(Collection collection, Function, Optional> fallback) { + return new SelectionSet(collection, fallback); + } + /** * If this {@code SelectionSet} contains exactly one element it gets returned. If no unique result can be identified * the fallback function passed in at the constructor gets called and its return value becomes the return value of diff --git a/src/main/java/org/springframework/data/repository/config/SpringDataAnnotationBeanNameGenerator.java b/src/main/java/org/springframework/data/repository/config/SpringDataAnnotationBeanNameGenerator.java index 87c39662d..f129fe019 100644 --- a/src/main/java/org/springframework/data/repository/config/SpringDataAnnotationBeanNameGenerator.java +++ b/src/main/java/org/springframework/data/repository/config/SpringDataAnnotationBeanNameGenerator.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.config; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanNameGenerator; @@ -33,10 +30,13 @@ import org.springframework.context.annotation.AnnotationBeanNameGenerator; * @since 2.0 * @soundtrack Nils WĂĽlker - Never Left At All (feat. Rob Summerfield) */ -@RequiredArgsConstructor class SpringDataAnnotationBeanNameGenerator { - private final @NonNull BeanNameGenerator delegate; + private final BeanNameGenerator delegate; + + public SpringDataAnnotationBeanNameGenerator(BeanNameGenerator delegate) { + this.delegate = delegate; + } /** * Generates a bean name for the given {@link BeanDefinition}. diff --git a/src/main/java/org/springframework/data/repository/core/support/AbstractEntityInformation.java b/src/main/java/org/springframework/data/repository/core/support/AbstractEntityInformation.java index 44bc74e4e..9f105f4ab 100644 --- a/src/main/java/org/springframework/data/repository/core/support/AbstractEntityInformation.java +++ b/src/main/java/org/springframework/data/repository/core/support/AbstractEntityInformation.java @@ -15,10 +15,8 @@ */ package org.springframework.data.repository.core.support; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.data.repository.core.EntityInformation; +import org.springframework.util.Assert; /** * Base class for implementations of {@link EntityInformation}. Considers an entity to be new whenever @@ -28,10 +26,16 @@ import org.springframework.data.repository.core.EntityInformation; * @author Nick Williams * @author Mark Paluch */ -@RequiredArgsConstructor public abstract class AbstractEntityInformation implements EntityInformation { - private final @NonNull Class domainClass; + private final Class domainClass; + + public AbstractEntityInformation(Class domainClass) { + + Assert.notNull(domainClass, "Domain class must not be null"); + + this.domainClass = domainClass; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/repository/core/support/DefaultRepositoryMetadata.java b/src/main/java/org/springframework/data/repository/core/support/DefaultRepositoryMetadata.java index 3cf5de85b..bbaf01f45 100644 --- a/src/main/java/org/springframework/data/repository/core/support/DefaultRepositoryMetadata.java +++ b/src/main/java/org/springframework/data/repository/core/support/DefaultRepositoryMetadata.java @@ -15,8 +15,6 @@ */ package org.springframework.data.repository.core.support; -import lombok.Getter; - import java.util.List; import java.util.function.Supplier; @@ -33,7 +31,6 @@ import org.springframework.util.Assert; * @author Oliver Gierke * @author Thomas Darimont */ -@Getter public class DefaultRepositoryMetadata extends AbstractRepositoryMetadata { private static final String MUST_BE_A_REPOSITORY = String.format("Given type must be assignable to %s!", @@ -71,4 +68,12 @@ public class DefaultRepositoryMetadata extends AbstractRepositoryMetadata { return arguments.get(index).getType(); } + + public Class getIdType() { + return this.idType; + } + + public Class getDomainType() { + return this.domainType; + } } diff --git a/src/main/java/org/springframework/data/repository/core/support/DelegatingEntityInformation.java b/src/main/java/org/springframework/data/repository/core/support/DelegatingEntityInformation.java index fb8656908..f8cbe9e3c 100644 --- a/src/main/java/org/springframework/data/repository/core/support/DelegatingEntityInformation.java +++ b/src/main/java/org/springframework/data/repository/core/support/DelegatingEntityInformation.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.core.support; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.data.repository.core.EntityInformation; import org.springframework.lang.Nullable; @@ -27,10 +24,13 @@ import org.springframework.lang.Nullable; * * @author Oliver Gierke */ -@RequiredArgsConstructor public class DelegatingEntityInformation implements EntityInformation { - private final @NonNull EntityInformation delegate; + private final EntityInformation delegate; + + public DelegatingEntityInformation(EntityInformation delegate) { + this.delegate = delegate; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/repository/core/support/EventPublishingRepositoryProxyPostProcessor.java b/src/main/java/org/springframework/data/repository/core/support/EventPublishingRepositoryProxyPostProcessor.java index 4d0bf006b..a92bf9f52 100644 --- a/src/main/java/org/springframework/data/repository/core/support/EventPublishingRepositoryProxyPostProcessor.java +++ b/src/main/java/org/springframework/data/repository/core/support/EventPublishingRepositoryProxyPostProcessor.java @@ -15,8 +15,6 @@ */ package org.springframework.data.repository.core.support; -import lombok.RequiredArgsConstructor; - import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Collection; @@ -26,6 +24,7 @@ import java.util.function.Supplier; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; + import org.springframework.aop.framework.ProxyFactory; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.AfterDomainEventPublication; @@ -51,11 +50,14 @@ import org.springframework.util.ReflectionUtils; * @since 1.13 * @soundtrack Henrik Freischlader Trio - Master Plan (Openness) */ -@RequiredArgsConstructor public class EventPublishingRepositoryProxyPostProcessor implements RepositoryProxyPostProcessor { private final ApplicationEventPublisher publisher; + public EventPublishingRepositoryProxyPostProcessor(ApplicationEventPublisher publisher) { + this.publisher = publisher; + } + /* * (non-Javadoc) * @see org.springframework.data.repository.core.support.RepositoryProxyPostProcessor#postProcess(org.springframework.aop.framework.ProxyFactory, org.springframework.data.repository.core.RepositoryInformation) @@ -78,12 +80,22 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr * @author Oliver Gierke * @since 1.13 */ - @RequiredArgsConstructor(staticName = "of") static class EventPublishingMethodInterceptor implements MethodInterceptor { private final EventPublishingMethod eventMethod; private final ApplicationEventPublisher publisher; + private EventPublishingMethodInterceptor(EventPublishingMethod eventMethod, ApplicationEventPublisher publisher) { + + this.eventMethod = eventMethod; + this.publisher = publisher; + } + + public static EventPublishingMethodInterceptor of(EventPublishingMethod eventMethod, + ApplicationEventPublisher publisher) { + return new EventPublishingMethodInterceptor(eventMethod, publisher); + } + /* * (non-Javadoc) * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) @@ -112,7 +124,6 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr * @author Oliver Gierke * @since 1.13 */ - @RequiredArgsConstructor static class EventPublishingMethod { private static Map, EventPublishingMethod> CACHE = new ConcurrentReferenceHashMap<>(); @@ -121,6 +132,12 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr private final Method publishingMethod; private final @Nullable Method clearingMethod; + EventPublishingMethod(Method publishingMethod, Method clearingMethod) { + + this.publishingMethod = publishingMethod; + this.clearingMethod = clearingMethod; + } + /** * Creates an {@link EventPublishingMethod} for the given type. * diff --git a/src/main/java/org/springframework/data/repository/core/support/MethodInvocationValidator.java b/src/main/java/org/springframework/data/repository/core/support/MethodInvocationValidator.java index 88d9758ff..7edd28556 100644 --- a/src/main/java/org/springframework/data/repository/core/support/MethodInvocationValidator.java +++ b/src/main/java/org/springframework/data/repository/core/support/MethodInvocationValidator.java @@ -15,16 +15,13 @@ */ package org.springframework.data.repository.core.support; -import lombok.AccessLevel; -import lombok.RequiredArgsConstructor; -import lombok.Value; - import java.lang.annotation.ElementType; import java.lang.reflect.Method; import java.util.Map; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; + import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.MethodParameter; import org.springframework.core.ParameterNameDiscoverer; @@ -35,6 +32,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.util.ConcurrentReferenceHashMap; import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType; +import org.springframework.util.ObjectUtils; /** * Interceptor enforcing required return value and method parameter constraints declared on repository query methods. @@ -105,13 +103,17 @@ public class MethodInvocationValidator implements MethodInterceptor { return result; } - @Value - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) - static class Nullability { + static final class Nullability { - boolean nullableReturn; - boolean[] nullableParameters; - MethodParameter[] methodParameters; + private final boolean nullableReturn; + private final boolean[] nullableParameters; + private final MethodParameter[] methodParameters; + + private Nullability(boolean nullableReturn, boolean[] nullableParameters, MethodParameter[] methodParameters) { + this.nullableReturn = nullableReturn; + this.nullableParameters = nullableParameters; + this.methodParameters = methodParameters; + } static Nullability of(Method method, ParameterNameDiscoverer discoverer) { @@ -160,5 +162,64 @@ public class MethodInvocationValidator implements MethodInterceptor { private static boolean requiresNoValue(MethodParameter parameter) { return parameter.getParameterType().equals(Void.class) || parameter.getParameterType().equals(Void.TYPE); } + + public boolean[] getNullableParameters() { + return this.nullableParameters; + } + + public MethodParameter[] getMethodParameters() { + return this.methodParameters; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Nullability)) { + return false; + } + + Nullability that = (Nullability) o; + + if (nullableReturn != that.nullableReturn) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(nullableParameters, that.nullableParameters)) { + return false; + } + + return ObjectUtils.nullSafeEquals(methodParameters, that.methodParameters); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = (nullableReturn ? 1 : 0); + result = 31 * result + ObjectUtils.nullSafeHashCode(nullableParameters); + result = 31 * result + ObjectUtils.nullSafeHashCode(methodParameters); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "MethodInvocationValidator.Nullability(nullableReturn=" + this.isNullableReturn() + ", nullableParameters=" + + java.util.Arrays.toString(this.getNullableParameters()) + ", methodParameters=" + + java.util.Arrays.deepToString(this.getMethodParameters()) + ")"; + } } } diff --git a/src/main/java/org/springframework/data/repository/core/support/MethodLookup.java b/src/main/java/org/springframework/data/repository/core/support/MethodLookup.java index dd5e840d7..bac38f6a7 100644 --- a/src/main/java/org/springframework/data/repository/core/support/MethodLookup.java +++ b/src/main/java/org/springframework/data/repository/core/support/MethodLookup.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.core.support; -import lombok.NonNull; -import lombok.Value; - import java.lang.reflect.Method; import java.util.List; import java.util.function.BiPredicate; @@ -25,6 +22,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Strategy interface providing {@link MethodPredicate predicates} to resolve a method called on a composite to its @@ -77,10 +75,18 @@ public interface MethodLookup { /** * Value object representing an invoked {@link Method}. */ - @Value(staticConstructor = "of") + final class InvokedMethod { - private final @NonNull Method method; + private final Method method; + + private InvokedMethod(Method method) { + this.method = method; + } + + public static InvokedMethod of(Method method) { + return new InvokedMethod(method); + } public Class getDeclaringClass() { return method.getDeclaringClass(); @@ -97,5 +103,46 @@ public interface MethodLookup { public int getParameterCount() { return method.getParameterCount(); } + + public Method getMethod() { + return this.method; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof InvokedMethod)) { + return false; + } + + InvokedMethod that = (InvokedMethod) o; + return ObjectUtils.nullSafeEquals(method, that.method); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(method); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "MethodLookup.InvokedMethod(method=" + this.getMethod() + ")"; + } } } diff --git a/src/main/java/org/springframework/data/repository/core/support/MethodLookups.java b/src/main/java/org/springframework/data/repository/core/support/MethodLookups.java index 8f1358f03..d5d60c1a9 100644 --- a/src/main/java/org/springframework/data/repository/core/support/MethodLookups.java +++ b/src/main/java/org/springframework/data/repository/core/support/MethodLookups.java @@ -17,8 +17,6 @@ package org.springframework.data.repository.core.support; import static org.springframework.core.GenericTypeResolver.*; -import lombok.Value; - import java.lang.reflect.GenericDeclaration; import java.lang.reflect.Method; import java.lang.reflect.Type; @@ -41,6 +39,7 @@ import org.springframework.data.repository.core.support.MethodLookup.MethodPredi import org.springframework.data.repository.util.QueryExecutionConverters; import org.springframework.data.repository.util.ReactiveWrapperConverters; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Implementations of method lookup functions. @@ -56,7 +55,7 @@ interface MethodLookups { * * @return direct method lookup. */ - public static MethodLookup direct() { + static MethodLookup direct() { MethodPredicate direct = (invoked, candidate) -> candidate.getName().equals(invoked.getName()) && candidate.getParameterCount() == invoked.getParameterCount() @@ -75,7 +74,7 @@ interface MethodLookups { * @return the composed, repository-aware method lookup. * @see #direct() */ - public static MethodLookup forRepositoryTypes(RepositoryMetadata repositoryMetadata) { + static MethodLookup forRepositoryTypes(RepositoryMetadata repositoryMetadata) { return direct().and(new RepositoryAwareMethodLookup(repositoryMetadata)); } @@ -92,7 +91,7 @@ interface MethodLookups { * @see #direct() * @see #forRepositoryTypes(RepositoryMetadata) */ - public static MethodLookup forReactiveTypes(RepositoryMetadata repositoryMetadata) { + static MethodLookup forReactiveTypes(RepositoryMetadata repositoryMetadata) { return direct().and(new ReactiveTypeInteropMethodLookup(repositoryMetadata)); } @@ -102,7 +101,7 @@ interface MethodLookups { * * @author Mark Paluch */ - static class RepositoryAwareMethodLookup implements MethodLookup { + class RepositoryAwareMethodLookup implements MethodLookup { @SuppressWarnings("rawtypes") private static final TypeVariable>[] PARAMETERS = Repository.class .getTypeParameters(); @@ -225,7 +224,7 @@ interface MethodLookups { * * @author Mark Paluch */ - static class ReactiveTypeInteropMethodLookup extends RepositoryAwareMethodLookup { + class ReactiveTypeInteropMethodLookup extends RepositoryAwareMethodLookup { private final RepositoryMetadata repositoryMetadata; @@ -395,12 +394,20 @@ interface MethodLookups { * parameters indexes are correlated so {@link ParameterOverrideCriteria} applies only to methods with same * parameter count. */ - @Value(staticConstructor = "of") - static class ParameterOverrideCriteria { + static final class ParameterOverrideCriteria { private final MethodParameter declared; private final MethodParameter base; + private ParameterOverrideCriteria(MethodParameter declared, MethodParameter base) { + this.declared = declared; + this.base = base; + } + + public static ParameterOverrideCriteria of(MethodParameter declared, MethodParameter base) { + return new ParameterOverrideCriteria(declared, base); + } + /** * @return base method parameter type. */ @@ -425,6 +432,59 @@ interface MethodLookups { public boolean isAssignableFromDeclared() { return getBaseType().isAssignableFrom(getDeclaredType()); } + + public MethodParameter getDeclared() { + return this.declared; + } + + public MethodParameter getBase() { + return this.base; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof ParameterOverrideCriteria)) { + return false; + } + + ParameterOverrideCriteria that = (ParameterOverrideCriteria) o; + + if (!ObjectUtils.nullSafeEquals(declared, that.declared)) { + return false; + } + + return ObjectUtils.nullSafeEquals(base, that.base); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(declared); + result = 31 * result + ObjectUtils.nullSafeHashCode(base); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "MethodLookups.ReactiveTypeInteropMethodLookup.ParameterOverrideCriteria(declared=" + this.getDeclared() + + ", base=" + this.getBase() + ")"; + } } } } diff --git a/src/main/java/org/springframework/data/repository/core/support/PersistentEntityInformation.java b/src/main/java/org/springframework/data/repository/core/support/PersistentEntityInformation.java index 999e32c11..28fc62a3c 100644 --- a/src/main/java/org/springframework/data/repository/core/support/PersistentEntityInformation.java +++ b/src/main/java/org/springframework/data/repository/core/support/PersistentEntityInformation.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.core.support; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentProperty; import org.springframework.data.repository.core.EntityInformation; @@ -30,12 +27,15 @@ import org.springframework.lang.Nullable; * @author Oliver Gierke * @author Christoph Strobl */ -@RequiredArgsConstructor public class PersistentEntityInformation implements EntityInformation { - private final @NonNull PersistentEntity> persistentEntity; + private final PersistentEntity> persistentEntity; - /* + public PersistentEntityInformation(PersistentEntity> persistentEntity) { + this.persistentEntity = persistentEntity; + } + + /* * (non-Javadoc) * @see org.springframework.data.repository.core.support.AbstractEntityInformation#isNew(java.lang.Object) */ @@ -55,7 +55,7 @@ public class PersistentEntityInformation implements EntityInformation PASSTHRU_ARG_CONVERTER = (methodParameter, o) -> o; @@ -73,9 +67,16 @@ public class RepositoryComposition { MethodLookups.direct(), PASSTHRU_ARG_CONVERTER); private final Map methodCache = new ConcurrentReferenceHashMap<>(); - private final @Getter RepositoryFragments fragments; - private final @Getter MethodLookup methodLookup; - private final @Getter BiFunction argumentConverter; + private final RepositoryFragments fragments; + private final MethodLookup methodLookup; + private final BiFunction argumentConverter; + + private RepositoryComposition(RepositoryFragments fragments, MethodLookup methodLookup, + BiFunction argumentConverter) { + this.fragments = fragments; + this.methodLookup = methodLookup; + this.argumentConverter = argumentConverter; + } /** * Create an empty {@link RepositoryComposition}. @@ -239,13 +240,51 @@ public class RepositoryComposition { ClassUtils.getQualifiedName(it.getSignatureContributor()))))); } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof RepositoryComposition)) { + return false; + } + + RepositoryComposition that = (RepositoryComposition) o; + return ObjectUtils.nullSafeEquals(fragments, that.fragments); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(fragments); + } + + public RepositoryFragments getFragments() { + return this.fragments; + } + + public MethodLookup getMethodLookup() { + return this.methodLookup; + } + + public BiFunction getArgumentConverter() { + return this.argumentConverter; + } + /** * Value object representing an ordered list of {@link RepositoryFragment fragments}. * * @author Mark Paluch */ - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) - @EqualsAndHashCode public static class RepositoryFragments implements Streamable> { static final RepositoryFragments EMPTY = new RepositoryFragments(Collections.emptyList()); @@ -254,6 +293,10 @@ public class RepositoryComposition { private final Map invocationMetadataCache = new ConcurrentHashMap<>(); private final List> fragments; + private RepositoryFragments(List> fragments) { + this.fragments = fragments; + } + /** * Create empty {@link RepositoryFragments}. * @@ -416,5 +459,45 @@ public class RepositoryComposition { public String toString() { return fragments.toString(); } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof RepositoryFragments)) { + return false; + } + + RepositoryFragments that = (RepositoryFragments) o; + + if (!ObjectUtils.nullSafeEquals(fragmentCache, that.fragmentCache)) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(invocationMetadataCache, that.invocationMetadataCache)) { + return false; + } + + return ObjectUtils.nullSafeEquals(fragments, that.fragments); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(fragmentCache); + result = 31 * result + ObjectUtils.nullSafeHashCode(invocationMetadataCache); + result = 31 * result + ObjectUtils.nullSafeHashCode(fragments); + return result; + } } } diff --git a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java index 28f226a38..8e737c546 100644 --- a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java +++ b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java @@ -15,13 +15,6 @@ */ package org.springframework.data.repository.core.support; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.Value; -import lombok.extern.slf4j.Slf4j; - import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.ArrayList; @@ -34,6 +27,7 @@ import java.util.stream.Collectors; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; +import org.slf4j.Logger; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.interceptor.ExposeInvocationInterceptor; @@ -68,6 +62,7 @@ import org.springframework.transaction.interceptor.TransactionalProxy; import org.springframework.util.Assert; import org.springframework.util.ConcurrentReferenceHashMap; import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType; +import org.springframework.util.ObjectUtils; /** * Factory bean to create instances of a given repository interface. Creates a proxy implementing the configured @@ -79,7 +74,6 @@ import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType; * @author Christoph Strobl * @author Jens Schauder */ -@Slf4j public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, BeanFactoryAware { private static final BiFunction REACTIVE_ARGS_CONVERTER = (method, args) -> { @@ -114,6 +108,7 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, }; final static GenericConversionService CONVERSION_SERVICE = new DefaultConversionService(); + private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(RepositoryFactorySupport.class); static { QueryExecutionConverters.registerConvertersIn(CONVERSION_SERVICE); @@ -529,10 +524,13 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, * * @author Mark Paluch */ - @RequiredArgsConstructor public class ImplementationMethodExecutionInterceptor implements MethodInterceptor { - private final @NonNull RepositoryComposition composition; + private final RepositoryComposition composition; + + public ImplementationMethodExecutionInterceptor(RepositoryComposition composition) { + this.composition = composition; + } /* * (non-Javadoc) @@ -561,7 +559,6 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, * * @author Oliver Gierke */ - @Getter private static class QueryCollectingQueryCreationListener implements QueryCreationListener { /** @@ -576,6 +573,10 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, public void onCreation(RepositoryQuery query) { this.queryMethods.add(query.getQueryMethod()); } + + public List getQueryMethods() { + return this.queryMethods; + } } /** @@ -584,12 +585,10 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, * @author Oliver Gierke * @author Mark Paluch */ - @EqualsAndHashCode - @Value - private static class RepositoryInformationCacheKey { + private static final class RepositoryInformationCacheKey { - String repositoryInterfaceName; - final long compositionHash; + private final String repositoryInterfaceName; + private final long compositionHash; /** * Creates a new {@link RepositoryInformationCacheKey} for the given {@link RepositoryMetadata} and composition. @@ -602,5 +601,58 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, this.repositoryInterfaceName = metadata.getRepositoryInterface().getName(); this.compositionHash = composition.hashCode(); } + + public RepositoryInformationCacheKey(String repositoryInterfaceName, long compositionHash) { + this.repositoryInterfaceName = repositoryInterfaceName; + this.compositionHash = compositionHash; + } + + public String getRepositoryInterfaceName() { + return this.repositoryInterfaceName; + } + + public long getCompositionHash() { + return this.compositionHash; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof RepositoryInformationCacheKey)) { + return false; + } + RepositoryInformationCacheKey that = (RepositoryInformationCacheKey) o; + if (compositionHash != that.compositionHash) { + return false; + } + return ObjectUtils.nullSafeEquals(repositoryInterfaceName, that.repositoryInterfaceName); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(repositoryInterfaceName); + result = 31 * result + (int) (compositionHash ^ (compositionHash >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "RepositoryFactorySupport.RepositoryInformationCacheKey(repositoryInterfaceName=" + + this.getRepositoryInterfaceName() + ", compositionHash=" + this.getCompositionHash() + ")"; + } } } diff --git a/src/main/java/org/springframework/data/repository/core/support/RepositoryFragment.java b/src/main/java/org/springframework/data/repository/core/support/RepositoryFragment.java index 4ba968d7c..7b4a5dce3 100644 --- a/src/main/java/org/springframework/data/repository/core/support/RepositoryFragment.java +++ b/src/main/java/org/springframework/data/repository/core/support/RepositoryFragment.java @@ -15,10 +15,6 @@ */ package org.springframework.data.repository.core.support; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.lang.reflect.Method; import java.util.Arrays; import java.util.Optional; @@ -26,6 +22,7 @@ import java.util.stream.Stream; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; /** @@ -55,7 +52,7 @@ public interface RepositoryFragment { * @param implementation must not be {@literal null}. * @return */ - public static RepositoryFragment implemented(T implementation) { + static RepositoryFragment implemented(T implementation) { return new ImplementedRepositoryFragment(Optional.empty(), implementation); } @@ -66,7 +63,7 @@ public interface RepositoryFragment { * @param implementation must not be {@literal null}. * @return */ - public static RepositoryFragment implemented(Class interfaceClass, T implementation) { + static RepositoryFragment implemented(Class interfaceClass, T implementation) { return new ImplementedRepositoryFragment<>(Optional.of(interfaceClass), implementation); } @@ -76,7 +73,7 @@ public interface RepositoryFragment { * @param interfaceOrImplementation must not be {@literal null}. * @return */ - public static RepositoryFragment structural(Class interfaceOrImplementation) { + static RepositoryFragment structural(Class interfaceOrImplementation) { return new StructuralRepositoryFragment<>(interfaceOrImplementation); } @@ -122,11 +119,13 @@ public interface RepositoryFragment { */ RepositoryFragment withImplementation(T implementation); - @RequiredArgsConstructor - @EqualsAndHashCode(callSuper = false) - static class StructuralRepositoryFragment implements RepositoryFragment { + class StructuralRepositoryFragment implements RepositoryFragment { - private final @NonNull Class interfaceOrImplementation; + private final Class interfaceOrImplementation; + + public StructuralRepositoryFragment(Class interfaceOrImplementation) { + this.interfaceOrImplementation = interfaceOrImplementation; + } /* * (non-Javadoc) @@ -146,17 +145,45 @@ public interface RepositoryFragment { return new ImplementedRepositoryFragment<>(Optional.of(interfaceOrImplementation), implementation); } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return String.format("StructuralRepositoryFragment %s", ClassUtils.getShortName(interfaceOrImplementation)); } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof StructuralRepositoryFragment)) { + return false; + } + + StructuralRepositoryFragment that = (StructuralRepositoryFragment) o; + return ObjectUtils.nullSafeEquals(interfaceOrImplementation, that.interfaceOrImplementation); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(interfaceOrImplementation); + } } - @EqualsAndHashCode(callSuper = false) - static class ImplementedRepositoryFragment implements RepositoryFragment { + class ImplementedRepositoryFragment implements RepositoryFragment { private final Optional> interfaceClass; private final T implementation; @@ -223,5 +250,45 @@ public interface RepositoryFragment { interfaceClass.map(ClassUtils::getShortName).map(it -> it + ":").orElse(""), ClassUtils.getShortName(implementation.getClass())); } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof ImplementedRepositoryFragment)) { + return false; + } + + ImplementedRepositoryFragment that = (ImplementedRepositoryFragment) o; + + if (!ObjectUtils.nullSafeEquals(interfaceClass, that.interfaceClass)) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(implementation, that.implementation)) { + return false; + } + + return ObjectUtils.nullSafeEquals(optionalImplementation, that.optionalImplementation); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(interfaceClass); + result = 31 * result + ObjectUtils.nullSafeHashCode(implementation); + result = 31 * result + ObjectUtils.nullSafeHashCode(optionalImplementation); + return result; + } } } diff --git a/src/main/java/org/springframework/data/repository/core/support/TransactionalRepositoryProxyPostProcessor.java b/src/main/java/org/springframework/data/repository/core/support/TransactionalRepositoryProxyPostProcessor.java index b9e613dc2..a5e6a5861 100644 --- a/src/main/java/org/springframework/data/repository/core/support/TransactionalRepositoryProxyPostProcessor.java +++ b/src/main/java/org/springframework/data/repository/core/support/TransactionalRepositoryProxyPostProcessor.java @@ -245,6 +245,10 @@ class TransactionalRepositoryProxyPostProcessor implements RepositoryProxyPostPr return this.publicMethodsOnly; } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ @Override public boolean equals(Object other) { if (this == other) { @@ -258,6 +262,10 @@ class TransactionalRepositoryProxyPostProcessor implements RepositoryProxyPostPr && this.publicMethodsOnly == otherTas.publicMethodsOnly); } + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ @Override public int hashCode() { return this.annotationParsers.hashCode(); @@ -489,6 +497,10 @@ class TransactionalRepositoryProxyPostProcessor implements RepositoryProxyPostPr this.targetClass = targetClass; } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ @Override public boolean equals(Object other) { if (this == other) { @@ -502,6 +514,10 @@ class TransactionalRepositoryProxyPostProcessor implements RepositoryProxyPostPr && ObjectUtils.nullSafeEquals(this.targetClass, otherKey.targetClass); } + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ @Override public int hashCode() { return this.method.hashCode() * 29 + (this.targetClass != null ? this.targetClass.hashCode() : 0); diff --git a/src/main/java/org/springframework/data/repository/query/ExtensionAwareQueryMethodEvaluationContextProvider.java b/src/main/java/org/springframework/data/repository/query/ExtensionAwareQueryMethodEvaluationContextProvider.java index f0d64ba78..dceb137e3 100644 --- a/src/main/java/org/springframework/data/repository/query/ExtensionAwareQueryMethodEvaluationContextProvider.java +++ b/src/main/java/org/springframework/data/repository/query/ExtensionAwareQueryMethodEvaluationContextProvider.java @@ -15,8 +15,6 @@ */ package org.springframework.data.repository.query; -import lombok.RequiredArgsConstructor; - import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; @@ -27,6 +25,7 @@ import java.util.stream.Stream; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; + import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.data.spel.ExtensionAwareEvaluationContextProvider; import org.springframework.data.spel.spi.EvaluationContextExtension; @@ -141,7 +140,6 @@ public class ExtensionAwareQueryMethodEvaluationContextProvider implements Query * * @author Oliver Gierke */ - @RequiredArgsConstructor static class DelegatingMethodInterceptor implements MethodInterceptor { private static final Map METHOD_CACHE = new ConcurrentReferenceHashMap(); @@ -149,6 +147,10 @@ public class ExtensionAwareQueryMethodEvaluationContextProvider implements Query private final Object target; private final Map> directMappings = new HashMap<>(); + DelegatingMethodInterceptor(Object target) { + this.target = target; + } + /** * Registers a result mapping for the method with the given name. Invocation results for matching methods will be * piped through the mapping. diff --git a/src/main/java/org/springframework/data/repository/query/ResultProcessor.java b/src/main/java/org/springframework/data/repository/query/ResultProcessor.java index a892b9ff4..c01e1b8d5 100644 --- a/src/main/java/org/springframework/data/repository/query/ResultProcessor.java +++ b/src/main/java/org/springframework/data/repository/query/ResultProcessor.java @@ -15,11 +15,6 @@ */ package org.springframework.data.repository.query; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -27,8 +22,6 @@ import java.util.List; import java.util.Map; import java.util.stream.Stream; -import javax.annotation.Nonnull; - import org.springframework.core.CollectionFactory; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.converter.Converter; @@ -49,7 +42,6 @@ import org.springframework.util.Assert; * @author Christoph Strobl * @since 1.12 */ -@AllArgsConstructor(access = AccessLevel.PRIVATE) public class ResultProcessor { private final QueryMethod method; @@ -86,6 +78,14 @@ public class ResultProcessor { this.factory = factory; } + private ResultProcessor(QueryMethod method, ProjectingConverter converter, ProjectionFactory factory, + ReturnedType type) { + this.method = method; + this.converter = converter; + this.factory = factory; + this.type = type; + } + /** * Returns a new {@link ResultProcessor} with a new projection type obtained from the given {@link ParameterAccessor}. * @@ -192,11 +192,19 @@ public class ResultProcessor { } } - @RequiredArgsConstructor(staticName = "of") private static class ChainingConverter implements Converter { - private final @NonNull Class targetType; - private final @NonNull Converter delegate; + private final Class targetType; + private final Converter delegate; + + private ChainingConverter(Class targetType, Converter delegate) { + this.targetType = targetType; + this.delegate = delegate; + } + + public static ChainingConverter of(Class targetType, Converter delegate) { + return new ChainingConverter(targetType, delegate); + } /** * Returns a new {@link ChainingConverter} that hands the elements resulting from the current conversion to the @@ -243,19 +251,17 @@ public class ResultProcessor { * (non-Javadoc) * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object) */ - @Nonnull @Override public Object convert(Object source) { return source; } } - @RequiredArgsConstructor private static class ProjectingConverter implements Converter { - private final @NonNull ReturnedType type; - private final @NonNull ProjectionFactory factory; - private final @NonNull ConversionService conversionService; + private final ReturnedType type; + private final ProjectionFactory factory; + private final ConversionService conversionService; /** * Creates a new {@link ProjectingConverter} for the given {@link ReturnedType} and {@link ProjectionFactory}. @@ -267,6 +273,12 @@ public class ResultProcessor { this(type, factory, DefaultConversionService.getSharedInstance()); } + public ProjectingConverter(ReturnedType type, ProjectionFactory factory, ConversionService conversionService) { + this.type = type; + this.factory = factory; + this.conversionService = conversionService; + } + /** * Creates a new {@link ProjectingConverter} for the given {@link ReturnedType}. * diff --git a/src/main/java/org/springframework/data/repository/query/ReturnedType.java b/src/main/java/org/springframework/data/repository/query/ReturnedType.java index cabb727af..e89c5df74 100644 --- a/src/main/java/org/springframework/data/repository/query/ReturnedType.java +++ b/src/main/java/org/springframework/data/repository/query/ReturnedType.java @@ -15,11 +15,6 @@ */ package org.springframework.data.repository.query; -import lombok.AccessLevel; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.Value; - import java.beans.PropertyDescriptor; import java.util.ArrayList; import java.util.Arrays; @@ -39,6 +34,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ConcurrentReferenceHashMap; +import org.springframework.util.ObjectUtils; /** * A representation of the type returned by a {@link QueryMethod}. @@ -48,12 +44,15 @@ import org.springframework.util.ConcurrentReferenceHashMap; * @author Mark Paluch * @since 1.12 */ -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) public abstract class ReturnedType { private static final Map CACHE = new ConcurrentReferenceHashMap<>(32); - private final @NonNull Class domainType; + private final Class domainType; + + private ReturnedType(Class domainType) { + this.domainType = domainType; + } /** * Creates a new {@link ReturnedType} for the given returned type, domain type and {@link ProjectionFactory}. @@ -330,9 +329,82 @@ public abstract class ReturnedType { } } - @Value(staticConstructor = "of") - private static class CacheKey { - Class returnedType, domainType; - int projectionFactoryHashCode; + private static final class CacheKey { + + private final Class returnedType, domainType; + private final int projectionFactoryHashCode; + + private CacheKey(Class returnedType, Class domainType, int projectionFactoryHashCode) { + + this.returnedType = returnedType; + this.domainType = domainType; + this.projectionFactoryHashCode = projectionFactoryHashCode; + } + + public static CacheKey of(Class returnedType, Class domainType, int projectionFactoryHashCode) { + return new CacheKey(returnedType, domainType, projectionFactoryHashCode); + } + + public Class getReturnedType() { + return this.returnedType; + } + + public Class getDomainType() { + return this.domainType; + } + + public int getProjectionFactoryHashCode() { + return this.projectionFactoryHashCode; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof CacheKey)) { + return false; + } + + CacheKey cacheKey = (CacheKey) o; + + if (projectionFactoryHashCode != cacheKey.projectionFactoryHashCode) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(returnedType, cacheKey.returnedType)) { + return false; + } + + return ObjectUtils.nullSafeEquals(domainType, cacheKey.domainType); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(returnedType); + result = 31 * result + ObjectUtils.nullSafeHashCode(domainType); + result = 31 * result + projectionFactoryHashCode; + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ReturnedType.CacheKey(returnedType=" + this.getReturnedType() + ", domainType=" + this.getDomainType() + + ", projectionFactoryHashCode=" + this.getProjectionFactoryHashCode() + ")"; + } } } diff --git a/src/main/java/org/springframework/data/repository/query/SpelEvaluator.java b/src/main/java/org/springframework/data/repository/query/SpelEvaluator.java index 8b465c0a0..633832224 100644 --- a/src/main/java/org/springframework/data/repository/query/SpelEvaluator.java +++ b/src/main/java/org/springframework/data/repository/query/SpelEvaluator.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.query; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.util.Map; import java.util.stream.Collectors; @@ -37,14 +34,20 @@ import org.springframework.util.Assert; * @since 2.1 * @see SpelQueryContext#parse(String, Parameters) */ -@RequiredArgsConstructor public class SpelEvaluator { private final static SpelExpressionParser PARSER = new SpelExpressionParser(); - private final @NonNull QueryMethodEvaluationContextProvider evaluationContextProvider; - private final @NonNull Parameters parameters; - private final @NonNull SpelExtractor extractor; + private final QueryMethodEvaluationContextProvider evaluationContextProvider; + private final Parameters parameters; + private final SpelExtractor extractor; + + public SpelEvaluator(QueryMethodEvaluationContextProvider evaluationContextProvider, Parameters parameters, + SpelExtractor extractor) { + this.evaluationContextProvider = evaluationContextProvider; + this.parameters = parameters; + this.extractor = extractor; + } /** * Evaluate all the SpEL expressions in {@link #parameterNameToSpelMap} based on values provided as an argument. @@ -66,7 +69,7 @@ public class SpelEvaluator { /** * Returns the query string produced by the intermediate SpEL expression collection step. - * + * * @return */ public String getQueryString() { diff --git a/src/main/java/org/springframework/data/repository/query/SpelQueryContext.java b/src/main/java/org/springframework/data/repository/query/SpelQueryContext.java index d3f39f63b..86e34310f 100644 --- a/src/main/java/org/springframework/data/repository/query/SpelQueryContext.java +++ b/src/main/java/org/springframework/data/repository/query/SpelQueryContext.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.query; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -44,7 +41,6 @@ import org.springframework.util.Assert; * @author Mark Paluch * @since 2.1 */ -@RequiredArgsConstructor(staticName = "of") public class SpelQueryContext { private final static String SPEL_PATTERN_STRING = "([:?])#\\{([^}]+)}"; @@ -55,7 +51,7 @@ public class SpelQueryContext { * be used in place of the SpEL expression. A typical implementation is expected to look like * (index, spel) -> "__some_placeholder_" + index */ - private final @NonNull BiFunction parameterNameSource; + private final BiFunction parameterNameSource; /** * A function from a prefix used to demarcate a SpEL expression in a query and a parameter name as returned from @@ -64,7 +60,22 @@ public class SpelQueryContext { * typical implementation is expected to look like (prefix, name) -> prefix + name or * (prefix, name) -> "{" + name + "}" */ - private final @NonNull BiFunction replacementSource; + private final BiFunction replacementSource; + + private SpelQueryContext(BiFunction parameterNameSource, + BiFunction replacementSource) { + + Assert.notNull(parameterNameSource, "Parameter name source must not be null"); + Assert.notNull(replacementSource, "Replacement source must not be null"); + + this.parameterNameSource = parameterNameSource; + this.replacementSource = replacementSource; + } + + public static SpelQueryContext of(BiFunction parameterNameSource, + BiFunction replacementSource) { + return new SpelQueryContext(parameterNameSource, replacementSource); + } /** * Parses the query for SpEL expressions using the pattern: diff --git a/src/main/java/org/springframework/data/repository/query/parser/Part.java b/src/main/java/org/springframework/data/repository/query/parser/Part.java index b4b9ab80a..b5950ffb5 100644 --- a/src/main/java/org/springframework/data/repository/query/parser/Part.java +++ b/src/main/java/org/springframework/data/repository/query/parser/Part.java @@ -15,7 +15,6 @@ */ package org.springframework.data.repository.query.parser; -import lombok.EqualsAndHashCode; import java.beans.Introspector; import java.util.ArrayList; @@ -28,6 +27,7 @@ import java.util.regex.Pattern; import org.springframework.data.mapping.PropertyPath; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * A single part of a method name that has to be transformed into a query part. The actual transformation is defined by @@ -38,7 +38,6 @@ import org.springframework.util.Assert; * @author Martin Baumgartner * @author Jens Schauder */ -@EqualsAndHashCode public class Part { private static final Pattern IGNORE_CASE = Pattern.compile("Ignor(ing|e)Case"); @@ -131,6 +130,46 @@ public class Part { return ignoreCase; } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Part)) { + return false; + } + + Part part = (Part) o; + + if (!ObjectUtils.nullSafeEquals(propertyPath, part.propertyPath)) { + return false; + } + + if (type != part.type) { + return false; + } + + return ignoreCase == part.ignoreCase; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(propertyPath); + result = 31 * result + ObjectUtils.nullSafeHashCode(type); + result = 31 * result + ObjectUtils.nullSafeHashCode(ignoreCase); + return result; + } + /* * (non-Javadoc) * @see java.lang.Object#toString() diff --git a/src/main/java/org/springframework/data/repository/query/parser/PartTree.java b/src/main/java/org/springframework/data/repository/query/parser/PartTree.java index 136487509..ec7076d29 100644 --- a/src/main/java/org/springframework/data/repository/query/parser/PartTree.java +++ b/src/main/java/org/springframework/data/repository/query/parser/PartTree.java @@ -15,8 +15,6 @@ */ package org.springframework.data.repository.query.parser; -import lombok.Getter; - import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -256,6 +254,10 @@ public class PartTree implements Streamable { return children.iterator(); } + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ @Override public String toString() { return StringUtils.collectionToDelimitedString(children, " and "); @@ -365,7 +367,7 @@ public class PartTree implements Streamable { private static final String ORDER_BY = "OrderBy"; private final List nodes; - private final @Getter OrderBySource orderBySource; + private final OrderBySource orderBySource; private boolean alwaysIgnoreCase; public Predicate(String predicate, Class domainClass) { @@ -397,6 +399,10 @@ public class PartTree implements Streamable { return predicate; } + public OrderBySource getOrderBySource() { + return orderBySource; + } + /* * (non-Javadoc) * @see java.lang.Iterable#iterator() diff --git a/src/main/java/org/springframework/data/repository/support/AnnotationAttribute.java b/src/main/java/org/springframework/data/repository/support/AnnotationAttribute.java index ef0340820..6dac155d8 100644 --- a/src/main/java/org/springframework/data/repository/support/AnnotationAttribute.java +++ b/src/main/java/org/springframework/data/repository/support/AnnotationAttribute.java @@ -15,9 +15,6 @@ */ package org.springframework.data.repository.support; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.util.Optional; @@ -33,11 +30,10 @@ import org.springframework.util.Assert; * @author Christoph Strobl * @since 1.10 */ -@RequiredArgsConstructor class AnnotationAttribute { - private final @NonNull Class annotationType; - private final @NonNull Optional attributeName; + private final Class annotationType; + private final Optional attributeName; /** * Creates a new {@link AnnotationAttribute} to the {@code value} attribute of the given {@link Annotation} type. @@ -48,6 +44,15 @@ class AnnotationAttribute { this(annotationType, Optional.empty()); } + public AnnotationAttribute(Class annotationType, Optional attributeName) { + + Assert.notNull(annotationType, "Annotation type must not be null"); + Assert.notNull(attributeName, "Attribute name must not be null"); + + this.annotationType = annotationType; + this.attributeName = attributeName; + } + /** * Returns the annotation type. * diff --git a/src/main/java/org/springframework/data/repository/support/PageableExecutionUtils.java b/src/main/java/org/springframework/data/repository/support/PageableExecutionUtils.java index 202d5da1f..2ea62f4e6 100644 --- a/src/main/java/org/springframework/data/repository/support/PageableExecutionUtils.java +++ b/src/main/java/org/springframework/data/repository/support/PageableExecutionUtils.java @@ -15,8 +15,6 @@ */ package org.springframework.data.repository.support; -import lombok.experimental.UtilityClass; - import java.util.List; import java.util.function.LongSupplier; @@ -34,8 +32,9 @@ import org.springframework.util.Assert; * @author Christoph Strobl * @since 1.13 */ -@UtilityClass -public class PageableExecutionUtils { +public abstract class PageableExecutionUtils { + + private PageableExecutionUtils() {} /** * Constructs a {@link Page} based on the given {@code content}, {@link Pageable} and {@link Supplier} applying diff --git a/src/main/java/org/springframework/data/repository/util/QueryExecutionConverters.java b/src/main/java/org/springframework/data/repository/util/QueryExecutionConverters.java index 9c1891520..a25a04182 100644 --- a/src/main/java/org/springframework/data/repository/util/QueryExecutionConverters.java +++ b/src/main/java/org/springframework/data/repository/util/QueryExecutionConverters.java @@ -15,11 +15,6 @@ */ package org.springframework.data.repository.util; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.Value; import scala.Function0; import scala.Option; import scala.runtime.AbstractFunction0; @@ -37,8 +32,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; import java.util.stream.Stream; -import javax.annotation.Nonnull; - import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.ConditionalGenericConverter; @@ -52,11 +45,13 @@ import org.springframework.data.geo.GeoResults; import org.springframework.data.util.StreamUtils; import org.springframework.data.util.Streamable; import org.springframework.data.util.TypeInformation; +import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ConcurrentReferenceHashMap; +import org.springframework.util.ObjectUtils; import org.springframework.util.concurrent.ListenableFuture; import com.google.common.base.Optional; @@ -333,12 +328,11 @@ public abstract class QueryExecutionConverters { * * @author Oliver Gierke */ - @RequiredArgsConstructor private static abstract class AbstractWrapperTypeConverter implements GenericConverter { - private final @NonNull ConversionService conversionService; - private final @NonNull Object nullValue; - private final @NonNull Iterable> wrapperTypes; + private final ConversionService conversionService; + private final Object nullValue; + private final Iterable> wrapperTypes; /** * Creates a new {@link AbstractWrapperTypeConverter} using the given {@link ConversionService} and wrapper type. @@ -356,11 +350,18 @@ public abstract class QueryExecutionConverters { this.wrapperTypes = Collections.singleton(nullValue.getClass()); } + public AbstractWrapperTypeConverter(ConversionService conversionService, Object nullValue, + Iterable> wrapperTypes) { + this.conversionService = conversionService; + this.nullValue = nullValue; + this.wrapperTypes = wrapperTypes; + } + /* * (non-Javadoc) * @see org.springframework.core.convert.converter.GenericConverter#getConvertibleTypes() */ - @Nonnull + @Override public Set getConvertibleTypes() { @@ -678,7 +679,6 @@ public abstract class QueryExecutionConverters { } } - @RequiredArgsConstructor private static class IterableToStreamableConverter implements ConditionalGenericConverter { private static final TypeDescriptor STREAMABLE = TypeDescriptor.valueOf(Streamable.class); @@ -686,11 +686,13 @@ public abstract class QueryExecutionConverters { private final Map TARGET_TYPE_CACHE = new ConcurrentHashMap<>(); private final ConversionService conversionService = DefaultConversionService.getSharedInstance(); + public IterableToStreamableConverter() {} + /* * (non-Javadoc) * @see org.springframework.core.convert.converter.GenericConverter#getConvertibleTypes() */ - @org.springframework.lang.NonNull + @NonNull @Override public Set getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(Iterable.class, Object.class)); @@ -739,16 +741,72 @@ public abstract class QueryExecutionConverters { } } - @Value - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) - public static class WrapperType { + public static final class WrapperType { + + private WrapperType(Class type, Cardinality cardinality) { + this.type = type; + this.cardinality = cardinality; + } + + public Class getType() { + return this.type; + } + + public Cardinality getCardinality() { + return cardinality; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof WrapperType)) { + return false; + } + + WrapperType that = (WrapperType) o; + + if (!ObjectUtils.nullSafeEquals(type, that.type)) { + return false; + } + + return cardinality == that.cardinality; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(type); + result = 31 * result + ObjectUtils.nullSafeHashCode(cardinality); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "QueryExecutionConverters.WrapperType(type=" + this.getType() + ", cardinality=" + this.getCardinality() + + ")"; + } enum Cardinality { NONE, SINGLE, MULTI; } - Class type; - @Getter(AccessLevel.NONE) Cardinality cardinality; + private final Class type; + private final Cardinality cardinality; public static WrapperType singleValue(Class type) { return new WrapperType(type, Cardinality.SINGLE); diff --git a/src/main/java/org/springframework/data/repository/util/ReactiveWrapperConverters.java b/src/main/java/org/springframework/data/repository/util/ReactiveWrapperConverters.java index 0b32e02e5..4e10ab163 100644 --- a/src/main/java/org/springframework/data/repository/util/ReactiveWrapperConverters.java +++ b/src/main/java/org/springframework/data/repository/util/ReactiveWrapperConverters.java @@ -19,7 +19,6 @@ import io.reactivex.Flowable; import io.reactivex.Maybe; import kotlinx.coroutines.flow.Flow; import kotlinx.coroutines.reactive.ReactiveFlowKt; -import lombok.experimental.UtilityClass; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import rx.Observable; @@ -60,8 +59,7 @@ import org.springframework.util.ClassUtils; * @see ReactiveWrappers * @see ReactiveAdapterRegistry */ -@UtilityClass -public class ReactiveWrapperConverters { +public abstract class ReactiveWrapperConverters { private static final List> REACTIVE_WRAPPERS = new ArrayList<>(); private static final GenericConversionService GENERIC_CONVERSION_SERVICE = new GenericConversionService(); @@ -92,6 +90,8 @@ public class ReactiveWrapperConverters { registerConvertersIn(GENERIC_CONVERSION_SERVICE); } + private ReactiveWrapperConverters() {} + /** * Registers converters for wrapper types found on the classpath. * @@ -199,7 +199,7 @@ public class ReactiveWrapperConverters { * @author Mark Paluch * @author Christoph Strobl */ - private interface ReactiveTypeWrapper { + private static interface ReactiveTypeWrapper { /** * @return the wrapper class. @@ -219,7 +219,7 @@ public class ReactiveWrapperConverters { /** * Wrapper for Project Reactor's {@link Mono}. */ - private enum MonoWrapper implements ReactiveTypeWrapper> { + private static enum MonoWrapper implements ReactiveTypeWrapper> { INSTANCE; @@ -237,7 +237,7 @@ public class ReactiveWrapperConverters { /** * Wrapper for Project Reactor's {@link Flux}. */ - private enum FluxWrapper implements ReactiveTypeWrapper> { + private static enum FluxWrapper implements ReactiveTypeWrapper> { INSTANCE; @@ -254,7 +254,7 @@ public class ReactiveWrapperConverters { /** * Wrapper for Reactive Stream's {@link Publisher}. */ - private enum PublisherWrapper implements ReactiveTypeWrapper> { + private static enum PublisherWrapper implements ReactiveTypeWrapper> { INSTANCE; @@ -281,7 +281,7 @@ public class ReactiveWrapperConverters { /** * Wrapper for RxJava 1's {@link Single}. */ - private enum RxJava1SingleWrapper implements ReactiveTypeWrapper> { + private static enum RxJava1SingleWrapper implements ReactiveTypeWrapper> { INSTANCE; @@ -299,7 +299,7 @@ public class ReactiveWrapperConverters { /** * Wrapper for RxJava 1's {@link Observable}. */ - private enum RxJava1ObservableWrapper implements ReactiveTypeWrapper> { + private static enum RxJava1ObservableWrapper implements ReactiveTypeWrapper> { INSTANCE; @@ -317,7 +317,7 @@ public class ReactiveWrapperConverters { /** * Wrapper for RxJava 2's {@link io.reactivex.Single}. */ - private enum RxJava2SingleWrapper implements ReactiveTypeWrapper> { + private static enum RxJava2SingleWrapper implements ReactiveTypeWrapper> { INSTANCE; @@ -335,7 +335,7 @@ public class ReactiveWrapperConverters { /** * Wrapper for RxJava 2's {@link io.reactivex.Maybe}. */ - private enum RxJava2MaybeWrapper implements ReactiveTypeWrapper> { + private static enum RxJava2MaybeWrapper implements ReactiveTypeWrapper> { INSTANCE; @@ -353,7 +353,7 @@ public class ReactiveWrapperConverters { /** * Wrapper for RxJava 2's {@link io.reactivex.Observable}. */ - private enum RxJava2ObservableWrapper implements ReactiveTypeWrapper> { + private static enum RxJava2ObservableWrapper implements ReactiveTypeWrapper> { INSTANCE; @@ -371,7 +371,7 @@ public class ReactiveWrapperConverters { /** * Wrapper for RxJava 2's {@link io.reactivex.Flowable}. */ - private enum RxJava2FlowableWrapper implements ReactiveTypeWrapper> { + private static enum RxJava2FlowableWrapper implements ReactiveTypeWrapper> { INSTANCE; @@ -396,7 +396,7 @@ public class ReactiveWrapperConverters { * @author Mark Paluch * @author 2.0 */ - private enum PublisherToFluxConverter implements Converter, Flux> { + private static enum PublisherToFluxConverter implements Converter, Flux> { INSTANCE; @@ -413,7 +413,7 @@ public class ReactiveWrapperConverters { * @author Mark Paluch * @author 2.0 */ - private enum PublisherToMonoConverter implements Converter, Mono> { + private static enum PublisherToMonoConverter implements Converter, Mono> { INSTANCE; @@ -434,7 +434,7 @@ public class ReactiveWrapperConverters { * @author Mark Paluch * @author 2.3 */ - private enum PublisherToFlowConverter implements Converter, Flow> { + private static enum PublisherToFlowConverter implements Converter, Flow> { INSTANCE; @@ -448,7 +448,8 @@ public class ReactiveWrapperConverters { /** * A {@link ConverterFactory} that adapts between reactive types using {@link ReactiveAdapterRegistry}. */ - private enum ReactiveAdapterConverterFactory implements ConverterFactory, ConditionalConverter { + private static enum ReactiveAdapterConverterFactory + implements ConverterFactory, ConditionalConverter { INSTANCE; diff --git a/src/main/java/org/springframework/data/repository/util/ReactiveWrappers.java b/src/main/java/org/springframework/data/repository/util/ReactiveWrappers.java index dfaa3543f..1b8802d3d 100644 --- a/src/main/java/org/springframework/data/repository/util/ReactiveWrappers.java +++ b/src/main/java/org/springframework/data/repository/util/ReactiveWrappers.java @@ -15,7 +15,6 @@ */ package org.springframework.data.repository.util; -import lombok.experimental.UtilityClass; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -55,8 +54,7 @@ import org.springframework.util.ClassUtils; * @see Mono * @see Flux */ -@UtilityClass -public class ReactiveWrappers { +public abstract class ReactiveWrappers { private static final boolean PROJECT_REACTOR_PRESENT = ClassUtils.isPresent("reactor.core.publisher.Mono", ReactiveWrappers.class.getClassLoader()); @@ -72,12 +70,14 @@ public class ReactiveWrappers { && ClassUtils.isPresent("kotlinx.coroutines.reactive.ReactiveFlowKt", ReactiveWrappers.class.getClassLoader()) && ClassUtils.isPresent("kotlinx.coroutines.reactor.ReactorFlowKt", ReactiveWrappers.class.getClassLoader()); + private ReactiveWrappers() {} + /** * Enumeration of supported reactive libraries. * * @author Mark Paluch */ - public enum ReactiveLibrary { + public static enum ReactiveLibrary { PROJECT_REACTOR, RXJAVA1, RXJAVA2, KOTLIN_COROUTINES; } diff --git a/src/main/java/org/springframework/data/spel/EvaluationContextExtensionInformation.java b/src/main/java/org/springframework/data/spel/EvaluationContextExtensionInformation.java index 655aee604..bb01ff201 100644 --- a/src/main/java/org/springframework/data/spel/EvaluationContextExtensionInformation.java +++ b/src/main/java/org/springframework/data/spel/EvaluationContextExtensionInformation.java @@ -17,9 +17,6 @@ package org.springframework.data.spel; import static org.springframework.data.util.StreamUtils.*; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -109,7 +106,6 @@ class EvaluationContextExtensionInformation { * * @author Oliver Gierke */ - @Getter public static class ExtensionTypeInformation { /** @@ -150,7 +146,14 @@ class EvaluationContextExtensionInformation { return CollectionUtils.unmodifiableMultiValueMap(map); } - @RequiredArgsConstructor + public Map getProperties() { + return this.properties; + } + + public MultiValueMap getFunctions() { + return this.functions; + } + static class PublicMethodAndFieldFilter implements MethodFilter, FieldFilter { public static final PublicMethodAndFieldFilter STATIC = new PublicMethodAndFieldFilter(true); @@ -158,6 +161,10 @@ class EvaluationContextExtensionInformation { private final boolean staticOnly; + public PublicMethodAndFieldFilter(boolean staticOnly) { + this.staticOnly = staticOnly; + } + /* * (non-Javadoc) * @see org.springframework.util.ReflectionUtils.MethodFilter#matches(java.lang.reflect.Method) diff --git a/src/main/java/org/springframework/data/spel/ExtensionAwareEvaluationContextProvider.java b/src/main/java/org/springframework/data/spel/ExtensionAwareEvaluationContextProvider.java index a1ca53089..2c1a1057c 100644 --- a/src/main/java/org/springframework/data/spel/ExtensionAwareEvaluationContextProvider.java +++ b/src/main/java/org/springframework/data/spel/ExtensionAwareEvaluationContextProvider.java @@ -15,9 +15,6 @@ */ package org.springframework.data.spel; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -61,7 +58,6 @@ import org.springframework.util.Assert; * @author Jens Schauder * @since 2.1 */ -@RequiredArgsConstructor public class ExtensionAwareEvaluationContextProvider implements EvaluationContextProvider { private final Map, EvaluationContextExtensionInformation> extensionInformationCache = new ConcurrentHashMap<>(); @@ -95,6 +91,11 @@ public class ExtensionAwareEvaluationContextProvider implements EvaluationContex this(Lazy.of(extensions)); } + public ExtensionAwareEvaluationContextProvider( + Lazy> extensions) { + this.extensions = extensions; + } + /* (non-Javadoc) * @see org.springframework.data.jpa.repository.support.EvaluationContextProvider#getEvaluationContext() */ @@ -317,10 +318,13 @@ public class ExtensionAwareEvaluationContextProvider implements EvaluationContex * @author Oliver Gierke * @since 1.9 */ - @RequiredArgsConstructor private static class FunctionMethodExecutor implements MethodExecutor { - private final @NonNull Function function; + private final Function function; + + public FunctionMethodExecutor(Function function) { + this.function = function; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/support/ExampleMatcherAccessor.java b/src/main/java/org/springframework/data/support/ExampleMatcherAccessor.java index 79311d3f8..f23960f7c 100644 --- a/src/main/java/org/springframework/data/support/ExampleMatcherAccessor.java +++ b/src/main/java/org/springframework/data/support/ExampleMatcherAccessor.java @@ -15,9 +15,6 @@ */ package org.springframework.data.support; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.util.Collection; import org.springframework.data.domain.ExampleMatcher; @@ -33,10 +30,13 @@ import org.springframework.data.domain.ExampleMatcher.StringMatcher; * @author Jens Schauder * @since 1.12 */ -@RequiredArgsConstructor public class ExampleMatcherAccessor { - private final @NonNull ExampleMatcher matcher; + private final ExampleMatcher matcher; + + public ExampleMatcherAccessor(ExampleMatcher matcher) { + this.matcher = matcher; + } /** * Returns the {@link PropertySpecifier}s of the underlying {@link ExampleMatcher}. diff --git a/src/main/java/org/springframework/data/type/classreading/DefaultMethodsMetadataReader.java b/src/main/java/org/springframework/data/type/classreading/DefaultMethodsMetadataReader.java index c97f3333c..e730de08d 100644 --- a/src/main/java/org/springframework/data/type/classreading/DefaultMethodsMetadataReader.java +++ b/src/main/java/org/springframework/data/type/classreading/DefaultMethodsMetadataReader.java @@ -15,8 +15,6 @@ */ package org.springframework.data.type.classreading; -import lombok.Getter; - import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; @@ -46,7 +44,6 @@ import org.springframework.util.Assert; * @author Oliver Gierke * @since 2.1 */ -@Getter class DefaultMethodsMetadataReader implements MethodsMetadataReader { private final Resource resource; @@ -77,6 +74,22 @@ class DefaultMethodsMetadataReader implements MethodsMetadataReader { } } + public Resource getResource() { + return this.resource; + } + + public ClassMetadata getClassMetadata() { + return this.classMetadata; + } + + public AnnotationMetadata getAnnotationMetadata() { + return this.annotationMetadata; + } + + public MethodsMetadata getMethodsMetadata() { + return this.methodsMetadata; + } + /** * ASM class visitor which looks for the class name and implemented types as well as for the methods defined in the * class, exposing them through the {@link MethodsMetadata} interface. diff --git a/src/main/java/org/springframework/data/util/BeanLookup.java b/src/main/java/org/springframework/data/util/BeanLookup.java index 887f95a0c..247269868 100644 --- a/src/main/java/org/springframework/data/util/BeanLookup.java +++ b/src/main/java/org/springframework/data/util/BeanLookup.java @@ -15,8 +15,6 @@ */ package org.springframework.data.util; -import lombok.experimental.UtilityClass; - import java.util.Map; import javax.annotation.Nullable; @@ -29,19 +27,20 @@ import org.springframework.util.Assert; /** * Simple helper to allow lenient lookup of beans of a given type from a {@link ListableBeanFactory}. This is not user * facing API but a mere helper for Spring Data configuration code. - * + * * @author Oliver Gierke * @since 2.1 * @soundtrack Dave Matthews Band - Bartender (DMB Live 25) */ -@UtilityClass -public class BeanLookup { +public abstract class BeanLookup { + + private BeanLookup() {} /** * Returns a {@link Lazy} for the unique bean of the given type from the given {@link BeanFactory} (which needs to be * a {@link ListableBeanFactory}). The lookup will produce a {@link NoUniqueBeanDefinitionException} in case multiple * beans of the given type are available in the given {@link BeanFactory}. - * + * * @param type must not be {@literal null}. * @param beanFactory the {@link BeanFactory} to lookup the bean from. * @return a {@link Lazy} for the unique bean of the given type or the instance provided by the fallback in case no @@ -57,7 +56,7 @@ public class BeanLookup { /** * Looks up the unique bean of the given type from the given {@link ListableBeanFactory}. - * + * * @param type must not be {@literal null}. * @param beanFactory must not be {@literal null}. * @return diff --git a/src/main/java/org/springframework/data/util/Lazy.java b/src/main/java/org/springframework/data/util/Lazy.java index 75dda3485..276507ff2 100644 --- a/src/main/java/org/springframework/data/util/Lazy.java +++ b/src/main/java/org/springframework/data/util/Lazy.java @@ -15,17 +15,13 @@ */ package org.springframework.data.util; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; - import java.util.Optional; import java.util.function.Function; import java.util.function.Supplier; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Simple value type to delay the creation of an object using a {@link Supplier} returning the produced object for @@ -36,17 +32,25 @@ import org.springframework.util.Assert; * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor -@AllArgsConstructor(access = AccessLevel.PRIVATE) -@EqualsAndHashCode public class Lazy implements Supplier { private static final Lazy EMPTY = new Lazy<>(() -> null, null, true); private final Supplier supplier; + private @Nullable T value = null; private boolean resolved = false; + public Lazy(Supplier supplier) { + this.supplier = supplier; + } + + private Lazy(Supplier supplier, T value, boolean resolved) { + this.supplier = supplier; + this.value = value; + this.resolved = resolved; + } + /** * Creates a new {@link Lazy} to produce an object lazily. * @@ -216,4 +220,44 @@ public class Lazy implements Supplier { return value; } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Lazy)) { + return false; + } + + Lazy lazy = (Lazy) o; + + if (resolved != lazy.resolved) { + return false; + } + + if (!ObjectUtils.nullSafeEquals(supplier, lazy.supplier)) { + return false; + } + + return ObjectUtils.nullSafeEquals(value, lazy.value); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(supplier); + result = 31 * result + ObjectUtils.nullSafeHashCode(value); + result = 31 * result + (resolved ? 1 : 0); + return result; + } } diff --git a/src/main/java/org/springframework/data/util/LazyStreamable.java b/src/main/java/org/springframework/data/util/LazyStreamable.java index e1008aa14..f88701be5 100644 --- a/src/main/java/org/springframework/data/util/LazyStreamable.java +++ b/src/main/java/org/springframework/data/util/LazyStreamable.java @@ -15,8 +15,6 @@ */ package org.springframework.data.util; -import lombok.Value; - import java.util.Iterator; import java.util.function.Supplier; import java.util.stream.Stream; @@ -27,11 +25,18 @@ import java.util.stream.Stream; * @author Oliver Gierke * @since 2.0 */ -@Value(staticConstructor = "of") -class LazyStreamable implements Streamable { +final class LazyStreamable implements Streamable { private final Supplier> stream; + private LazyStreamable(Supplier> stream) { + this.stream = stream; + } + + public static LazyStreamable of(Supplier> stream) { + return new LazyStreamable(stream); + } + /* * (non-Javadoc) * @see java.lang.Iterable#iterator() @@ -49,4 +54,17 @@ class LazyStreamable implements Streamable { public Stream stream() { return stream.get(); } + + public Supplier> getStream() { + return this.stream; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "LazyStreamable(stream=" + this.getStream() + ")"; + } } diff --git a/src/main/java/org/springframework/data/util/MethodInvocationRecorder.java b/src/main/java/org/springframework/data/util/MethodInvocationRecorder.java index e778b04a9..afebb22ba 100644 --- a/src/main/java/org/springframework/data/util/MethodInvocationRecorder.java +++ b/src/main/java/org/springframework/data/util/MethodInvocationRecorder.java @@ -15,13 +15,6 @@ */ package org.springframework.data.util; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.ToString; -import lombok.Value; - import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Arrays; @@ -31,14 +24,14 @@ import java.util.Map; import java.util.Optional; import java.util.function.Function; -import javax.annotation.Nonnull; - import org.aopalliance.intercept.MethodInvocation; + import org.springframework.aop.framework.ProxyFactory; import org.springframework.core.CollectionFactory; import org.springframework.core.ResolvableType; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; @@ -49,7 +42,6 @@ import org.springframework.util.StringUtils; * @since 2.2 * @soundtrack The Intersphere - Don't Think Twice (The Grand Delusion) */ -@AllArgsConstructor(access = AccessLevel.PRIVATE) public class MethodInvocationRecorder { public static PropertyNameDetectionStrategy DEFAULT = DefaultPropertyNameDetectionStrategy.INSTANCE; @@ -64,6 +56,10 @@ public class MethodInvocationRecorder { this(Optional.empty()); } + private MethodInvocationRecorder(Optional interceptor) { + this.interceptor = interceptor; + } + /** * Creates a new {@link Recorded} for the given type. * @@ -169,13 +165,17 @@ public class MethodInvocationRecorder { } } - @Value - private static class InvocationInformation { + private static final class InvocationInformation { - static final InvocationInformation NOT_INVOKED = new InvocationInformation(new Unrecorded(), null); + private static final InvocationInformation NOT_INVOKED = new InvocationInformation(new Unrecorded(), null); - @NonNull Recorded recorded; - @Nullable Method invokedMethod; + private final Recorded recorded; + @Nullable private final Method invokedMethod; + + public InvocationInformation(Recorded recorded, Method invokedMethod) { + this.recorded = recorded; + this.invokedMethod = invokedMethod; + } @Nullable Object getCurrentInstance() { @@ -205,6 +205,60 @@ public class MethodInvocationRecorder { .orElseThrow(() -> new IllegalArgumentException( String.format("No property name found for method %s!", invokedMethod))); } + + public Recorded getRecorded() { + return this.recorded; + } + + @Nullable + public Method getInvokedMethod() { + return this.invokedMethod; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof InvocationInformation)) { + return false; + } + + InvocationInformation that = (InvocationInformation) o; + + if (!ObjectUtils.nullSafeEquals(recorded, that.recorded)) { + return false; + } + + return ObjectUtils.nullSafeEquals(invokedMethod, that.invokedMethod); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(recorded); + result = 31 * result + ObjectUtils.nullSafeHashCode(invokedMethod); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "MethodInvocationRecorder.InvocationInformation(recorded=" + this.getRecorded() + ", invokedMethod=" + + this.getInvokedMethod() + ")"; + } } public interface PropertyNameDetectionStrategy { @@ -213,7 +267,7 @@ public class MethodInvocationRecorder { String getPropertyName(Method method); } - private static enum DefaultPropertyNameDetectionStrategy implements PropertyNameDetectionStrategy { + private enum DefaultPropertyNameDetectionStrategy implements PropertyNameDetectionStrategy { INSTANCE; @@ -221,7 +275,7 @@ public class MethodInvocationRecorder { * (non-Javadoc) * @see org.springframework.hateoas.core.Recorder.PropertyNameDetectionStrategy#getPropertyName(java.lang.reflect.Method) */ - @Nonnull + @Override public String getPropertyName(Method method) { return getPropertyName(method.getReturnType(), method.getName()); @@ -240,13 +294,16 @@ public class MethodInvocationRecorder { } } - @ToString - @RequiredArgsConstructor public static class Recorded { private final @Nullable T currentInstance; private final @Nullable MethodInvocationRecorder recorder; + public Recorded(T currentInstance, MethodInvocationRecorder recorder) { + this.currentInstance = currentInstance; + this.recorder = recorder; + } + public Optional getPropertyPath() { return getPropertyPath(MethodInvocationRecorder.DEFAULT); } @@ -304,6 +361,16 @@ public class MethodInvocationRecorder { return new Recorded(converter.apply(currentInstance).values().iterator().next(), recorder); } + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "MethodInvocationRecorder.Recorded(currentInstance=" + this.currentInstance + ", recorder=" + this.recorder + + ")"; + } + public interface ToCollectionConverter extends Function> {} public interface ToMapConverter extends Function> {} diff --git a/src/main/java/org/springframework/data/util/MultiValueMapCollector.java b/src/main/java/org/springframework/data/util/MultiValueMapCollector.java index d35397659..696eb747c 100644 --- a/src/main/java/org/springframework/data/util/MultiValueMapCollector.java +++ b/src/main/java/org/springframework/data/util/MultiValueMapCollector.java @@ -15,10 +15,6 @@ */ package org.springframework.data.util; -import lombok.AccessLevel; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.util.EnumSet; import java.util.HashMap; import java.util.Set; @@ -37,11 +33,19 @@ import org.springframework.util.MultiValueMap; * @author Jens Schauder * @since 2.0 */ -@RequiredArgsConstructor(access = AccessLevel.PACKAGE, staticName = "of") class MultiValueMapCollector implements Collector, MultiValueMap> { - private final @NonNull Function keyFunction; - private final @NonNull Function valueFunction; + private final Function keyFunction; + private final Function valueFunction; + + private MultiValueMapCollector(Function keyFunction, Function valueFunction) { + this.keyFunction = keyFunction; + this.valueFunction = valueFunction; + } + + static MultiValueMapCollector of(Function keyFunction, Function valueFunction) { + return new MultiValueMapCollector(keyFunction, valueFunction); + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/util/NullableUtils.java b/src/main/java/org/springframework/data/util/NullableUtils.java index d2bf07bbc..f3b48f3e4 100644 --- a/src/main/java/org/springframework/data/util/NullableUtils.java +++ b/src/main/java/org/springframework/data/util/NullableUtils.java @@ -15,8 +15,6 @@ */ package org.springframework.data.util; -import lombok.experimental.UtilityClass; - import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.reflect.AnnotatedElement; @@ -81,8 +79,7 @@ import org.springframework.util.MultiValueMap; * @see Nullable * @see Nonnull */ -@UtilityClass -public class NullableUtils { +public abstract class NullableUtils { private static final String NON_NULL_CLASS_NAME = "javax.annotation.Nonnull"; private static final String TYPE_QUALIFIER_CLASS_NAME = "javax.annotation.meta.TypeQualifierDefault"; @@ -96,6 +93,8 @@ public class NullableUtils { private static final Set WHEN_NULLABLE = new HashSet<>(Arrays.asList("UNKNOWN", "MAYBE", "NEVER")); private static final Set WHEN_NON_NULLABLE = new HashSet<>(Collections.singletonList("ALWAYS")); + private NullableUtils() {} + /** * Determine whether {@link ElementType} in the scope of {@link Method} requires non-{@literal null} values. * Non-nullability rules are discovered from class and package annotations. Non-null is applied when @@ -106,7 +105,7 @@ public class NullableUtils { * @return {@literal true} if {@link ElementType} allows {@literal null} values by default. * @see #isNonNull(Annotation, ElementType) */ - public boolean isNonNull(Method method, ElementType elementType) { + public static boolean isNonNull(Method method, ElementType elementType) { return isNonNull(method.getDeclaringClass(), elementType) || isNonNull((AnnotatedElement) method, elementType); } @@ -120,7 +119,7 @@ public class NullableUtils { * @return {@literal true} if {@link ElementType} allows {@literal null} values by default. * @see #isNonNull(Annotation, ElementType) */ - public boolean isNonNull(Class type, ElementType elementType) { + public static boolean isNonNull(Class type, ElementType elementType) { return isNonNull(type.getPackage(), elementType) || isNonNull((AnnotatedElement) type, elementType); } @@ -133,7 +132,7 @@ public class NullableUtils { * @param elementType the element type. * @return {@literal true} if {@link ElementType} allows {@literal null} values by default. */ - public boolean isNonNull(AnnotatedElement element, ElementType elementType) { + public static boolean isNonNull(AnnotatedElement element, ElementType elementType) { for (Annotation annotation : element.getAnnotations()) { diff --git a/src/main/java/org/springframework/data/util/Pair.java b/src/main/java/org/springframework/data/util/Pair.java index 52042180a..0178d6277 100644 --- a/src/main/java/org/springframework/data/util/Pair.java +++ b/src/main/java/org/springframework/data/util/Pair.java @@ -15,17 +15,14 @@ */ package org.springframework.data.util; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.ToString; - import java.util.Map; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; + /** * A tuple of things. * @@ -36,13 +33,19 @@ import java.util.stream.Stream; * @param Type of the second thing. * @since 1.12 */ -@ToString -@EqualsAndHashCode -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) public final class Pair { - private final @NonNull S first; - private final @NonNull T second; + private final S first; + private final T second; + + private Pair(S first, T second) { + + Assert.notNull(first, "First must not be null!"); + Assert.notNull(second, "Second must not be null!"); + + this.first = first; + this.second = second; + } /** * Creates a new {@link Pair} for the given elements. @@ -81,4 +84,48 @@ public final class Pair { public static Collector, ?, Map> toMap() { return Collectors.toMap(Pair::getFirst, Pair::getSecond); } + + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Pair)) { + return false; + } + + Pair pair = (Pair) o; + + if (!ObjectUtils.nullSafeEquals(first, pair.first)) { + return false; + } + + return ObjectUtils.nullSafeEquals(second, pair.second); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(first); + result = 31 * result + ObjectUtils.nullSafeHashCode(second); + return result; + } + + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return String.format("%s->%s", this.first, this.second); + } } diff --git a/src/main/java/org/springframework/data/util/ParameterTypes.java b/src/main/java/org/springframework/data/util/ParameterTypes.java index b2f572090..97ed95881 100644 --- a/src/main/java/org/springframework/data/util/ParameterTypes.java +++ b/src/main/java/org/springframework/data/util/ParameterTypes.java @@ -15,9 +15,6 @@ */ package org.springframework.data.util; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; - import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -31,6 +28,7 @@ import java.util.stream.Collectors; import org.springframework.core.convert.TypeDescriptor; import org.springframework.util.Assert; import org.springframework.util.ConcurrentReferenceHashMap; +import org.springframework.util.ObjectUtils; import org.springframework.util.TypeUtils; /** @@ -43,8 +41,6 @@ import org.springframework.util.TypeUtils; * @since 2.1.7 * @soundtrack Signs, High Times - Tedeschi Trucks Band (Signs) */ -@EqualsAndHashCode(of = "types") -@RequiredArgsConstructor public class ParameterTypes { private static final TypeDescriptor OBJECT_DESCRIPTOR = TypeDescriptor.valueOf(Object.class); @@ -64,6 +60,11 @@ public class ParameterTypes { this.alternatives = Lazy.of(() -> getAlternatives()); } + public ParameterTypes(List types, Lazy> alternatives) { + this.types = types; + this.alternatives = alternatives; + } + /** * Returns the {@link ParameterTypes} for the given list of {@link TypeDescriptor}s. * @@ -276,13 +277,37 @@ public class ParameterTypes { return types.get(types.size() - 1); } + /* + * (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ParameterTypes)) { + return false; + } + ParameterTypes that = (ParameterTypes) o; + return ObjectUtils.nullSafeEquals(types, that.types); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(types); + } + /** * Extension of {@link ParameterTypes} that remembers the seed tail and only adds typed varargs if the current tail is * assignable to the seed one. * * @author Oliver Drotbohm */ - @EqualsAndHashCode(callSuper = true) static class ParentParameterTypes extends ParameterTypes { private final TypeDescriptor tail; @@ -317,5 +342,39 @@ public class ParameterTypes { ? Optional.empty() // : super.withLastVarArgs(); } + + /* + * (non-Javadoc) + * @see org.springframework.data.util.ParentTypeAwareTypeInformation#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof ParentParameterTypes)) { + return false; + } + + if (!super.equals(o)) { + return false; + } + + ParentParameterTypes that = (ParentParameterTypes) o; + return ObjectUtils.nullSafeEquals(tail, that.tail); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + ObjectUtils.nullSafeHashCode(tail); + return result; + } } } diff --git a/src/main/java/org/springframework/data/util/ParsingUtils.java b/src/main/java/org/springframework/data/util/ParsingUtils.java index 0dcffa8fb..d7fd5c280 100644 --- a/src/main/java/org/springframework/data/util/ParsingUtils.java +++ b/src/main/java/org/springframework/data/util/ParsingUtils.java @@ -15,8 +15,6 @@ */ package org.springframework.data.util; -import lombok.experimental.UtilityClass; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -31,8 +29,7 @@ import org.springframework.util.StringUtils; * @author Oliver Gierke * @since 1.5 */ -@UtilityClass -public class ParsingUtils { +public abstract class ParsingUtils { private static final String UPPER = "\\p{Lu}|\\P{InBASIC_LATIN}"; private static final String LOWER = "\\p{Ll}"; @@ -41,6 +38,8 @@ public class ParsingUtils { private static final Pattern CAMEL_CASE = Pattern.compile(CAMEL_CASE_REGEX); + private ParsingUtils() {} + /** * Splits up the given camel-case {@link String}. * diff --git a/src/main/java/org/springframework/data/util/ProxyUtils.java b/src/main/java/org/springframework/data/util/ProxyUtils.java index e2a38b279..0e12fd7d0 100644 --- a/src/main/java/org/springframework/data/util/ProxyUtils.java +++ b/src/main/java/org/springframework/data/util/ProxyUtils.java @@ -15,8 +15,6 @@ */ package org.springframework.data.util; -import lombok.experimental.UtilityClass; - import java.util.List; import java.util.Map; @@ -28,12 +26,11 @@ import org.springframework.util.ConcurrentReferenceHashMap; /** * Proxy type detection utilities, extensible via {@link ProxyDetector} registered via Spring factories. - * + * * @author Oliver Gierke * @soundtrack Victor Wooten - Cruising Altitude (Trypnotix) */ -@UtilityClass -public class ProxyUtils { +public abstract class ProxyUtils { private static Map, Class> USER_TYPES = new ConcurrentReferenceHashMap<>(); @@ -44,9 +41,11 @@ public class ProxyUtils { DETECTORS.add(ClassUtils::getUserClass); } + private ProxyUtils() {} + /** * Returns the user class for the given type. - * + * * @param type must not be {@literal null}. * @return */ @@ -68,7 +67,7 @@ public class ProxyUtils { /** * Returns the user class for the given source object. - * + * * @param source must not be {@literal null}. * @return */ @@ -84,11 +83,11 @@ public class ProxyUtils { * * @author Oliver Gierke */ - public interface ProxyDetector { + public static interface ProxyDetector { /** * Returns the user class for the given type. - * + * * @param type will never be {@literal null}. * @return */ diff --git a/src/main/java/org/springframework/data/util/ReflectionUtils.java b/src/main/java/org/springframework/data/util/ReflectionUtils.java index 828a264dc..417908e15 100644 --- a/src/main/java/org/springframework/data/util/ReflectionUtils.java +++ b/src/main/java/org/springframework/data/util/ReflectionUtils.java @@ -15,10 +15,6 @@ */ package org.springframework.data.util; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.experimental.UtilityClass; - import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -49,8 +45,11 @@ import org.springframework.util.ReflectionUtils.FieldFilter; * @author Mark Paluch * @since 1.5 */ -@UtilityClass -public class ReflectionUtils { +public final class ReflectionUtils { + + private ReflectionUtils() { + throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); + } /** * Creates an instance of the class with the given fully qualified name or returns the given default instance if the @@ -92,10 +91,13 @@ public class ReflectionUtils { * * @author Oliver Gierke */ - @RequiredArgsConstructor public static class AnnotationFieldFilter implements DescribedFieldFilter { - private final @NonNull Class annotationType; + private final Class annotationType; + + public AnnotationFieldFilter(Class annotationType) { + this.annotationType = annotationType; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/util/TypeDiscoverer.java b/src/main/java/org/springframework/data/util/TypeDiscoverer.java index 3bb3d90cc..908fc3acf 100644 --- a/src/main/java/org/springframework/data/util/TypeDiscoverer.java +++ b/src/main/java/org/springframework/data/util/TypeDiscoverer.java @@ -15,10 +15,6 @@ */ package org.springframework.data.util; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.beans.PropertyDescriptor; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -28,7 +24,16 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.lang.reflect.WildcardType; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -37,6 +42,7 @@ import org.springframework.core.GenericTypeResolver; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; /** @@ -573,12 +579,15 @@ class TypeDiscoverer implements TypeInformation { * @author Oliver Gierke * @since 1.11 */ - @EqualsAndHashCode - @RequiredArgsConstructor private static class SyntheticParamterizedType implements ParameterizedType { - private final @NonNull ClassTypeInformation typeInformation; - private final @NonNull List> typeParameters; + private final ClassTypeInformation typeInformation; + private final List> typeParameters; + + public SyntheticParamterizedType(ClassTypeInformation typeInformation, List> typeParameters) { + this.typeInformation = typeInformation; + this.typeParameters = typeParameters; + } /* * (non-Javadoc) @@ -614,5 +623,40 @@ class TypeDiscoverer implements TypeInformation { return result; } + + /* + * (non-Javadoc) + * @see org.springframework.data.util.ParentTypeAwareTypeInformation#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof SyntheticParamterizedType)) { + return false; + } + + SyntheticParamterizedType that = (SyntheticParamterizedType) o; + + if (!ObjectUtils.nullSafeEquals(typeInformation, that.typeInformation)) { + return false; + } + + return ObjectUtils.nullSafeEquals(typeParameters, that.typeParameters); + } + + /* + * (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(typeInformation); + result = 31 * result + ObjectUtils.nullSafeHashCode(typeParameters); + return result; + } } } diff --git a/src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java b/src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java index 509164931..0865224b8 100644 --- a/src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java +++ b/src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java @@ -15,7 +15,6 @@ */ package org.springframework.data.web; -import lombok.RequiredArgsConstructor; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; @@ -30,6 +29,7 @@ import java.util.Map; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; + import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.data.projection.Accessor; @@ -122,11 +122,14 @@ public class JsonProjectingMethodInterceptorFactory implements MethodInterceptor return false; } - @RequiredArgsConstructor private static class InputMessageProjecting implements MethodInterceptor { private final DocumentContext context; + public InputMessageProjecting(DocumentContext context) { + this.context = context; + } + /* * (non-Javadoc) * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) @@ -191,11 +194,14 @@ public class JsonProjectingMethodInterceptorFactory implements MethodInterceptor return Collections.singletonList("$.".concat(new Accessor(method).getPropertyName())); } - @RequiredArgsConstructor private static class ResolvableTypeRef extends TypeRef { private final ResolvableType type; + ResolvableTypeRef(ResolvableType type) { + this.type = type; + } + /* * (non-Javadoc) * @see com.jayway.jsonpath.TypeRef#getType() diff --git a/src/main/java/org/springframework/data/web/MapDataBinder.java b/src/main/java/org/springframework/data/web/MapDataBinder.java index 00783f602..64579714b 100644 --- a/src/main/java/org/springframework/data/web/MapDataBinder.java +++ b/src/main/java/org/springframework/data/web/MapDataBinder.java @@ -15,16 +15,11 @@ */ package org.springframework.data.web; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.beans.PropertyDescriptor; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; - import org.springframework.beans.AbstractPropertyAccessor; import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; @@ -47,6 +42,7 @@ import org.springframework.expression.spel.SpelEvaluationException; import org.springframework.expression.spel.SpelParserConfiguration; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.SimpleEvaluationContext; +import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.web.bind.WebDataBinder; @@ -80,7 +76,7 @@ class MapDataBinder extends WebDataBinder { * (non-Javadoc) * @see org.springframework.validation.DataBinder#getTarget() */ - @Nonnull + @NonNull @Override @SuppressWarnings("unchecked") public Map getTarget() { @@ -110,15 +106,21 @@ class MapDataBinder extends WebDataBinder { * @author Oliver Gierke * @since 1.10 */ - @RequiredArgsConstructor private static class MapPropertyAccessor extends AbstractPropertyAccessor { private static final SpelExpressionParser PARSER = new SpelExpressionParser( new SpelParserConfiguration(false, true)); - private final @NonNull Class type; - private final @NonNull Map map; - private final @NonNull ConversionService conversionService; + private final Class type; + private final Map map; + private final ConversionService conversionService; + + public MapPropertyAccessor(Class type, Map map, ConversionService conversionService) { + + this.type = type; + this.map = map; + this.conversionService = conversionService; + } /* * (non-Javadoc)