DATACMNS-1726 - Delombok source files.
This commit is contained in:
@@ -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<Auditable<Object, ?, TemporalAccessor>> {
|
||||
|
||||
private final @NonNull Auditable<Object, ?, TemporalAccessor> auditable;
|
||||
private final Auditable<Object, ?, TemporalAccessor> auditable;
|
||||
private final Class<? extends TemporalAccessor> type;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -187,11 +184,14 @@ class DefaultAuditableBeanWrapperFactory implements AuditableBeanWrapperFactory
|
||||
* @author Oliver Gierke
|
||||
* @since 1.8
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
abstract static class DateConvertingAuditableBeanWrapper<T> implements AuditableBeanWrapper<T> {
|
||||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
DateConvertingAuditableBeanWrapper(ConversionService conversionService) {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link TemporalAccessor} in a type, compatible to the given field.
|
||||
*
|
||||
|
||||
@@ -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<?>, 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 + '}';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<S, T>
|
||||
implements ConverterAware, ReadingConverterBuilder<T, S>, WritingConverterBuilder<S, T> {
|
||||
|
||||
private final @NonNull ConvertiblePair convertiblePair;
|
||||
private final @NonNull Optional<Function<? super S, ? extends T>> writing;
|
||||
private final @NonNull Optional<Function<? super T, ? extends S>> reading;
|
||||
private final ConvertiblePair convertiblePair;
|
||||
private final Optional<Function<? super S, ? extends T>> writing;
|
||||
private final Optional<Function<? super T, ? extends S>> reading;
|
||||
|
||||
DefaultConverterBuilder(ConvertiblePair convertiblePair, Optional<Function<? super S, ? extends T>> writing,
|
||||
Optional<Function<? super T, ? extends S>> reading) {
|
||||
this.convertiblePair = convertiblePair;
|
||||
this.writing = writing;
|
||||
this.reading = reading;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -121,13 +120,26 @@ class DefaultConverterBuilder<S, T>
|
||||
return new ConvertiblePair(convertiblePair.getTargetType(), convertiblePair.getSourceType());
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
DefaultConverterBuilder<S, T> withWriting(Optional<Function<? super S, ? extends T>> writing) {
|
||||
return this.writing == writing ? this
|
||||
: new DefaultConverterBuilder<S, T>(this.convertiblePair, writing, this.reading);
|
||||
}
|
||||
|
||||
DefaultConverterBuilder<S, T> withReading(Optional<Function<? super T, ? extends S>> reading) {
|
||||
return this.reading == reading ? this
|
||||
: new DefaultConverterBuilder<S, T>(this.convertiblePair, this.writing, reading);
|
||||
}
|
||||
|
||||
private static class ConfigurableGenericConverter<S, T> implements GenericConverter {
|
||||
|
||||
private final ConvertiblePair convertiblePair;
|
||||
private final Function<? super S, ? extends T> function;
|
||||
|
||||
public ConfigurableGenericConverter(ConvertiblePair convertiblePair, Function<? super S, ? extends T> 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<S, T>
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.core.convert.converter.GenericConverter#getConvertibleTypes()
|
||||
*/
|
||||
@Nonnull
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> 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<S, T> extends ConfigurableGenericConverter<S, T> {
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<T> implements Slice<T>, Serializable {
|
||||
private static final long serialVersionUID = 867755909294344406L;
|
||||
|
||||
private final List<T> 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<T> implements Slice<T>, 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<T> implements Slice<T>, 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;
|
||||
|
||||
@@ -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<Object> transformValue(Optional<Object> 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<String, PropertySpecifier> propertySpecifiers = new LinkedHashMap<>();
|
||||
@@ -737,6 +828,34 @@ public interface ExampleMatcher {
|
||||
public Collection<PropertySpecifier> 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<T extends Comparable<T>> {
|
||||
public final class Range<T extends Comparable<T>> {
|
||||
|
||||
private final static Range<?> UNBOUNDED = Range.of(Bound.unbounded(), Bound.UNBOUNDED);
|
||||
|
||||
/**
|
||||
* The lower bound of the range.
|
||||
*/
|
||||
private final @NonNull Bound<T> lowerBound;
|
||||
private final Bound<T> lowerBound;
|
||||
|
||||
/**
|
||||
* The upper bound of the range.
|
||||
*/
|
||||
private final @NonNull Bound<T> upperBound;
|
||||
private final Bound<T> upperBound;
|
||||
|
||||
private Range(Bound<T> lowerBound, Bound<T> 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<T extends Comparable<T>> {
|
||||
return String.format("%s-%s", lowerBound.toPrefixString(), upperBound.toSuffixString());
|
||||
}
|
||||
|
||||
public Range.Bound<T> getLowerBound() {
|
||||
return this.lowerBound;
|
||||
}
|
||||
|
||||
public Range.Bound<T> 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<T extends Comparable<T>> {
|
||||
* @since 2.0
|
||||
* @soundtrack Mohamed Ragab - Excelsior Sessions (March 2017)
|
||||
*/
|
||||
@Value
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public static class Bound<T extends Comparable<T>> {
|
||||
public static final class Bound<T extends Comparable<T>> {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" }) //
|
||||
private static final Bound<?> UNBOUNDED = new Bound(Optional.empty(), true);
|
||||
@@ -221,6 +265,11 @@ public class Range<T extends Comparable<T>> {
|
||||
private final Optional<T> value;
|
||||
private final boolean inclusive;
|
||||
|
||||
private Bound(Optional<T> value, boolean inclusive) {
|
||||
this.value = value;
|
||||
this.inclusive = inclusive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unbounded {@link Bound}.
|
||||
*/
|
||||
@@ -367,6 +416,47 @@ public class Range<T extends Comparable<T>> {
|
||||
return value.map(Object::toString).orElse("unbounded");
|
||||
}
|
||||
|
||||
public Optional<T> 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<org.springframework.data.domain.Sort.Order>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5737186511678863905L;
|
||||
@@ -55,6 +51,10 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
|
||||
|
||||
private final List<Order> orders;
|
||||
|
||||
protected Sort(List<Order> orders) {
|
||||
this.orders = orders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Sort} instance.
|
||||
*
|
||||
|
||||
@@ -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<T> implements Example<T> {
|
||||
|
||||
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 + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String> 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<String> 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 + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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<Distance> {
|
||||
public final class Distance implements Serializable, Comparable<Distance> {
|
||||
|
||||
private static final long serialVersionUID = 2460886201934027744L;
|
||||
|
||||
@@ -192,4 +190,49 @@ public class Distance implements Serializable, Comparable<Distance> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T> extends PageImpl<GeoResult<T>> {
|
||||
/**
|
||||
* 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<T> extends PageImpl<GeoResult<T>> {
|
||||
public int hashCode() {
|
||||
return super.hashCode() + ObjectUtils.nullSafeHashCode(this.averageDistance);
|
||||
}
|
||||
|
||||
public Distance getAverageDistance() {
|
||||
return this.averageDistance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T> implements Serializable {
|
||||
public final class GeoResult<T> 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)
|
||||
|
||||
@@ -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<T> implements Iterable<GeoResult<T>>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8347363491300219485L;
|
||||
@@ -105,6 +104,41 @@ public class GeoResults<T> implements Iterable<GeoResult<T>>, Serializable {
|
||||
return (Iterator<GeoResult<T>>) 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()
|
||||
|
||||
@@ -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<Point>, Shape {
|
||||
|
||||
private static final long serialVersionUID = -2705040068154648988L;
|
||||
@@ -101,6 +100,34 @@ public class Polygon implements Iterable<Point>, 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()
|
||||
|
||||
@@ -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<N extends Number & Comparable<N>, T> implements Comparable<Revision<N, ?>> {
|
||||
|
||||
/**
|
||||
* The {@link RevisionMetadata} for the current {@link Revision}.
|
||||
*/
|
||||
@NonNull RevisionMetadata<N> metadata;
|
||||
private final RevisionMetadata<N> metadata;
|
||||
|
||||
/**
|
||||
* The underlying entity.
|
||||
*/
|
||||
@NonNull T entity;
|
||||
|
||||
private final T entity;
|
||||
|
||||
private Revision(RevisionMetadata<N> 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<N extends Number & Comparable<N>, T> implements Comp
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return String.format("Revision %s of entity %s - Revision metadata %s",
|
||||
getRevisionNumber().map(Object::toString).orElse("<unknown>"), entity, metadata);
|
||||
}
|
||||
|
||||
public RevisionMetadata<N> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<PersistentProperty<?>, Function<Object, Object>> handlers;
|
||||
private final @With @Getter GetNulls nullValues;
|
||||
private final GetNulls nullValues;
|
||||
|
||||
public GetOptions(Map<PersistentProperty<?>, Function<Object, Object>> 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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T, P extends PersistentProperty<P>> {
|
||||
* @param <T> the type of the parameter
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@EqualsAndHashCode(exclude = { "enclosingClassCache", "hasSpelExpression" })
|
||||
public static class Parameter<T, P extends PersistentProperty<P>> {
|
||||
|
||||
private final @Nullable String name;
|
||||
@@ -285,6 +283,51 @@ public class PreferredConstructor<T, P extends PersistentProperty<P>> {
|
||||
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}.
|
||||
*
|
||||
|
||||
@@ -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<PropertyPath> {
|
||||
|
||||
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<PropertyPath> {
|
||||
|
||||
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<PropertyPath> {
|
||||
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<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 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<PropertyPath> {
|
||||
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() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<E extends MutablePersistentEntity<?
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
private final class PersistentPropertyCreator implements FieldCallback {
|
||||
|
||||
private final @NonNull E entity;
|
||||
private final @NonNull Map<String, PropertyDescriptor> descriptors;
|
||||
private final @NonNull Map<String, PropertyDescriptor> remainingDescriptors;
|
||||
private final E entity;
|
||||
private final Map<String, PropertyDescriptor> descriptors;
|
||||
private final Map<String, PropertyDescriptor> remainingDescriptors;
|
||||
|
||||
public PersistentPropertyCreator(E entity, Map<String, PropertyDescriptor> descriptors) {
|
||||
this(entity, descriptors, descriptors);
|
||||
}
|
||||
|
||||
private PersistentPropertyCreator(E entity, Map<String, PropertyDescriptor> descriptors,
|
||||
Map<String, PropertyDescriptor> remainingDescriptors) {
|
||||
this.entity = entity;
|
||||
this.descriptors = descriptors;
|
||||
this.remainingDescriptors = remainingDescriptors;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.util.ReflectionUtils.FieldCallback#doWith(java.lang.reflect.Field)
|
||||
|
||||
@@ -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<P extends PersistentProperty<P>> implements PersistentPropertyPath<P> {
|
||||
|
||||
private static final Converter<PersistentProperty<?>, String> DEFAULT_CONVERTER = (source) -> source.getName();
|
||||
@@ -247,6 +245,34 @@ class DefaultPersistentPropertyPath<P extends PersistentProperty<P>> 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()
|
||||
|
||||
@@ -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<E extends PersistentEntity<?, P>, P extends PersistentProperty<P>> {
|
||||
|
||||
private static final Predicate<PersistentProperty<? extends PersistentProperty<?>>> IS_ENTITY = it -> it.isEntity();
|
||||
@@ -67,9 +52,13 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, P extends
|
||||
private final Map<TypeAndPath, PersistentPropertyPath<P>> propertyPaths = new ConcurrentReferenceHashMap<>();
|
||||
private final MappingContext<E, P> context;
|
||||
|
||||
public PersistentPropertyPathFactory(MappingContext<E, P> 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<E extends PersistentEntity<?, P>, 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<E extends PersistentEntity<?, P>, 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<E extends PersistentEntity<?, P>, 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<E extends PersistentEntity<?, P>, 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<E extends PersistentEntity<?, P>, 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<E extends PersistentEntity<?, P>, 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<E extends PersistentEntity<?, P>, 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<T, P extends PersistentProperty<P>>
|
||||
implements PersistentPropertyPaths<T, P> {
|
||||
|
||||
@@ -295,9 +342,14 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, P extends
|
||||
private final TypeInformation<T> type;
|
||||
private final Iterable<PersistentPropertyPath<P>> paths;
|
||||
|
||||
private DefaultPersistentPropertyPaths(TypeInformation<T> type, Iterable<PersistentPropertyPath<P>> paths) {
|
||||
this.type = type;
|
||||
this.paths = paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link DefaultPersistentPropertyPaths} instance
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* @param paths
|
||||
* @return
|
||||
@@ -312,7 +364,7 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, P extends
|
||||
return new DefaultPersistentPropertyPaths<>(type, sorted);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mapping.PersistentPropertyPaths#getFirst()
|
||||
*/
|
||||
@@ -321,7 +373,7 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, 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<E extends PersistentEntity<?, P>, 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<E extends PersistentEntity<?, P>, P extends
|
||||
return stream().anyMatch(it -> dotPath.equals(it.toDotPath()));
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
*/
|
||||
@@ -373,14 +425,24 @@ class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, 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<PersistentPropertyPath<? extends PersistentProperty<?>>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -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<P extends PersistentProperty<P>
|
||||
private final TypeInformation<?> information;
|
||||
private final Class<?> rawType;
|
||||
private final Lazy<Association<P>> association;
|
||||
private final @Getter PersistentEntity<?, P> owner;
|
||||
private final PersistentEntity<?, P> owner;
|
||||
|
||||
@SuppressWarnings("null") //
|
||||
private final @Getter(value = AccessLevel.PROTECTED, onMethod = @__(@SuppressWarnings("null"))) Property property;
|
||||
private final Property property;
|
||||
private final Lazy<Integer> hashCode;
|
||||
private final Lazy<Boolean> usePropertyAccess;
|
||||
private final Lazy<Optional<? extends TypeInformation<?>>> 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<?, P> owner,
|
||||
@@ -104,6 +101,15 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
|
||||
|
||||
protected abstract Association<P> createAssociation();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mapping.PersistentProperty#getOwner()
|
||||
*/
|
||||
@Override
|
||||
public PersistentEntity<?, P> getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mapping.PersistentProperty#getName()
|
||||
@@ -156,6 +162,42 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
|
||||
.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<P extends PersistentProperty<P>
|
||||
return usePropertyAccess.get();
|
||||
}
|
||||
|
||||
@SuppressWarnings("null")
|
||||
protected Property getProperty() {
|
||||
return this.property;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
|
||||
@@ -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<T, P extends PersistentProperty<P>> 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<T, P extends PersistentProperty<P>> 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<T, P extends PersistentProperty<P>> implement
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
private static final class AssociationComparator<P extends PersistentProperty<P>>
|
||||
implements Comparator<Association<P>>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4508054194886854513L;
|
||||
private final @NonNull Comparator<P> delegate;
|
||||
private final Comparator<P> delegate;
|
||||
|
||||
AssociationComparator(Comparator<P> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<PropertyStackAddress> {
|
||||
|
||||
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<P extends PersistentProperty<P>>
|
||||
implements ParameterValueProvider<P> {
|
||||
|
||||
private final @NonNull PersistentEntity<?, P> entity;
|
||||
private final @NonNull PropertyValueProvider<P> provider;
|
||||
private final PersistentEntity<?, P> entity;
|
||||
private final PropertyValueProvider<P> provider;
|
||||
private final @Nullable Object parent;
|
||||
|
||||
public PersistentEntityParameterValueProvider(PersistentEntity<?, P> entity, PropertyValueProvider<P> 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)
|
||||
|
||||
@@ -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> field;
|
||||
private final Optional<Field> field;
|
||||
private final Optional<PropertyDescriptor> 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<Field> getField() {
|
||||
return this.field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the property exposes a getter or a setter.
|
||||
*
|
||||
|
||||
@@ -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<T> implements PersistentPropertyPathAccessor<T> {
|
||||
|
||||
private final @NonNull PersistentPropertyAccessor<T> delegate;
|
||||
private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SimplePersistentPropertyPathAccessor.class);
|
||||
|
||||
private final PersistentPropertyAccessor<T> delegate;
|
||||
|
||||
public SimplePersistentPropertyPathAccessor(PersistentPropertyAccessor<T> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -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<P extends PersistentProperty<P>>
|
||||
implements ParameterValueProvider<P> {
|
||||
|
||||
private final @NonNull SpELExpressionEvaluator evaluator;
|
||||
private final @NonNull ConversionService conversionService;
|
||||
private final @NonNull ParameterValueProvider<P> delegate;
|
||||
private final SpELExpressionEvaluator evaluator;
|
||||
private final ConversionService conversionService;
|
||||
private final ParameterValueProvider<P> delegate;
|
||||
|
||||
public SpELExpressionParameterValueProvider(SpELExpressionEvaluator evaluator, ConversionService conversionService,
|
||||
ParameterValueProvider<P> delegate) {
|
||||
|
||||
this.evaluator = evaluator;
|
||||
this.conversionService = conversionService;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -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<MethodsMetadata> metadata;
|
||||
|
||||
|
||||
@@ -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<String, Object> map;
|
||||
private final Map<String, Object> map;
|
||||
|
||||
MapAccessingMethodInterceptor(Map<String, Object> map) {
|
||||
|
||||
Assert.notNull(map, "Map must not be null");
|
||||
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()) + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}.
|
||||
*
|
||||
|
||||
@@ -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 + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T> {
|
||||
|
||||
private final @NonNull Class<T> type;
|
||||
private final Class<T> type;
|
||||
|
||||
public TypeBinder(Class<T> 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<P extends Path<? extends T>, T> {
|
||||
private static final class PathAndBinding<P extends Path<? extends T>, T> {
|
||||
|
||||
@NonNull Optional<Path<?>> path;
|
||||
@NonNull Optional<MultiValueBinding<P, T>> binding;
|
||||
private final Optional<Path<?>> path;
|
||||
private final Optional<MultiValueBinding<P, T>> binding;
|
||||
|
||||
PathAndBinding(Optional<Path<?>> path, Optional<MultiValueBinding<P, T>> binding) {
|
||||
this.path = path;
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
public static <T, P extends Path<? extends T>> PathAndBinding<P, T> withPath(P path) {
|
||||
return new PathAndBinding<>(Optional.of(path), Optional.empty());
|
||||
@@ -528,5 +532,52 @@ public class QuerydslBindings {
|
||||
public PathAndBinding<P, T> with(MultiValueBinding<P, T> binding) {
|
||||
return new PathAndBinding<>(path, Optional.of(binding));
|
||||
}
|
||||
|
||||
public Optional<Path<?>> getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public Optional<MultiValueBinding<P, T>> 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() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<TypeFilter> getExcludeFilters() {
|
||||
return Streamable.empty();
|
||||
}
|
||||
|
||||
public MetadataReaderFactory getMetadataReaderFactory() {
|
||||
return this.metadataReaderFactory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T extends RepositoryConfigurationSource>
|
||||
implements RepositoryConfiguration<T> {
|
||||
|
||||
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)
|
||||
|
||||
@@ -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<ContextRefreshedEvent>, 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<Co
|
||||
LOG.info("Spring Data repositories initialized!");
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.core.Ordered#getOrder()
|
||||
*/
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.repository.config;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
@@ -30,19 +28,22 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Value object for a discovered Repository fragment interface.
|
||||
*
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Oliver Gierke
|
||||
* @since 2.1
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class FragmentMetadata {
|
||||
|
||||
private final MetadataReaderFactory factory;
|
||||
|
||||
public FragmentMetadata(MetadataReaderFactory factory) {
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all interfaces to be considered fragment ones for the given source interface.
|
||||
*
|
||||
*
|
||||
* @param interfaceName must not be {@literal null} or empty.
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.repository.config;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -26,7 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.springframework.beans.factory.config.DependencyDescriptor;
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
@@ -42,6 +39,7 @@ import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
@@ -55,7 +53,6 @@ import org.springframework.util.StopWatch;
|
||||
* @author Jens Schauder
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Slf4j
|
||||
public class RepositoryConfigurationDelegate {
|
||||
|
||||
private static final String REPOSITORY_REGISTRATION = "Spring Data {} - Registering repository: {} - Interface: {} - Factory: {}";
|
||||
@@ -64,6 +61,8 @@ public class RepositoryConfigurationDelegate {
|
||||
|
||||
static final String FACTORY_BEAN_OBJECT_TYPE = "factoryBeanObjectType";
|
||||
|
||||
private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(RepositoryConfigurationDelegate.class);
|
||||
|
||||
private final RepositoryConfigurationSource configurationSource;
|
||||
private final ResourceLoader resourceLoader;
|
||||
private final Environment environment;
|
||||
@@ -259,12 +258,15 @@ public class RepositoryConfigurationDelegate {
|
||||
* @author Oliver Gierke
|
||||
* @since 2.1
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
static class LazyRepositoryInjectionPointResolver extends ContextAnnotationAutowireCandidateResolver {
|
||||
|
||||
private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(LazyRepositoryInjectionPointResolver.class);
|
||||
private final Map<String, RepositoryConfiguration<?>> configurations;
|
||||
|
||||
public LazyRepositoryInjectionPointResolver(Map<String, RepositoryConfiguration<?>> configurations) {
|
||||
this.configurations = configurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link LazyRepositoryInjectionPointResolver} that will have its configurations augmented with the
|
||||
* given ones.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<AbstractBeanDefinition> beanDefinition;
|
||||
private final String interfaceName, className;
|
||||
private final Optional<AbstractBeanDefinition> 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<AbstractBeanDefinition> 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<AbstractBeanDefinition> 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() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T> {
|
||||
|
||||
private final Collection<T> collection;
|
||||
private final Function<Collection<T>, Optional<T>> fallback;
|
||||
|
||||
private SelectionSet(Collection<T> collection, Function<Collection<T>, Optional<T>> 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<T> {
|
||||
return new SelectionSet<>(collection, defaultFallback());
|
||||
}
|
||||
|
||||
public static <T> SelectionSet<T> of(Collection<T> collection, Function<Collection<T>, Optional<T>> fallback) {
|
||||
return new SelectionSet<T>(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
|
||||
|
||||
@@ -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}.
|
||||
|
||||
@@ -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<T, ID> implements EntityInformation<T, ID> {
|
||||
|
||||
private final @NonNull Class<T> domainClass;
|
||||
private final Class<T> domainClass;
|
||||
|
||||
public AbstractEntityInformation(Class<T> domainClass) {
|
||||
|
||||
Assert.notNull(domainClass, "Domain class must not be null");
|
||||
|
||||
this.domainClass = domainClass;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T, ID> implements EntityInformation<T, ID> {
|
||||
|
||||
private final @NonNull EntityInformation<T, ID> delegate;
|
||||
private final EntityInformation<T, ID> delegate;
|
||||
|
||||
public DelegatingEntityInformation(EntityInformation<T, ID> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -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<Class<?>, 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.
|
||||
*
|
||||
|
||||
@@ -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()) + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Class<Repository>>[] 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() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T, ID> implements EntityInformation<T, ID> {
|
||||
|
||||
private final @NonNull PersistentEntity<T, ? extends PersistentProperty<?>> persistentEntity;
|
||||
private final PersistentEntity<T, ? extends PersistentProperty<?>> persistentEntity;
|
||||
|
||||
/*
|
||||
public PersistentEntityInformation(PersistentEntity<T, ? extends PersistentProperty<?>> 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<T, ID> implements EntityInformation<T,
|
||||
return (ID) persistentEntity.getIdentifierAccessor(entity).getIdentifier();
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.core.EntityMetadata#getJavaType()
|
||||
*/
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.repository.core.support;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.data.repository.core.NamedQueries;
|
||||
@@ -28,14 +25,17 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class PropertiesBasedNamedQueries implements NamedQueries {
|
||||
|
||||
private static final String NO_QUERY_FOUND = "No query with name %s found! Make sure you call hasQuery(…) before calling this method!";
|
||||
|
||||
public static final NamedQueries EMPTY = new PropertiesBasedNamedQueries(new Properties());
|
||||
|
||||
private final @NonNull Properties properties;
|
||||
private final Properties properties;
|
||||
|
||||
public PropertiesBasedNamedQueries(Properties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -15,11 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.repository.core.support;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -42,6 +37,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;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -64,8 +60,6 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @since 2.0
|
||||
* @see RepositoryFragment
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@EqualsAndHashCode(of = "fragments")
|
||||
public class RepositoryComposition {
|
||||
|
||||
private static final BiFunction<Method, Object[], Object[]> PASSTHRU_ARG_CONVERTER = (methodParameter, o) -> o;
|
||||
@@ -73,9 +67,16 @@ public class RepositoryComposition {
|
||||
MethodLookups.direct(), PASSTHRU_ARG_CONVERTER);
|
||||
|
||||
private final Map<Method, Method> methodCache = new ConcurrentReferenceHashMap<>();
|
||||
private final @Getter RepositoryFragments fragments;
|
||||
private final @Getter MethodLookup methodLookup;
|
||||
private final @Getter BiFunction<Method, Object[], Object[]> argumentConverter;
|
||||
private final RepositoryFragments fragments;
|
||||
private final MethodLookup methodLookup;
|
||||
private final BiFunction<Method, Object[], Object[]> argumentConverter;
|
||||
|
||||
private RepositoryComposition(RepositoryFragments fragments, MethodLookup methodLookup,
|
||||
BiFunction<Method, Object[], Object[]> 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<Method, Object[], Object[]> 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<RepositoryFragment<?>> {
|
||||
|
||||
static final RepositoryFragments EMPTY = new RepositoryFragments(Collections.emptyList());
|
||||
@@ -254,6 +293,10 @@ public class RepositoryComposition {
|
||||
private final Map<Method, ImplementationInvocationMetadata> invocationMetadataCache = new ConcurrentHashMap<>();
|
||||
private final List<RepositoryFragment<?>> fragments;
|
||||
|
||||
private RepositoryFragments(List<RepositoryFragment<?>> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Method, Object[], Object[]> 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<RepositoryQuery> {
|
||||
|
||||
/**
|
||||
@@ -576,6 +573,10 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware,
|
||||
public void onCreation(RepositoryQuery query) {
|
||||
this.queryMethods.add(query.getQueryMethod());
|
||||
}
|
||||
|
||||
public List<QueryMethod> 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() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T> {
|
||||
* @param implementation must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
public static <T> RepositoryFragment<T> implemented(T implementation) {
|
||||
static <T> RepositoryFragment<T> implemented(T implementation) {
|
||||
return new ImplementedRepositoryFragment<T>(Optional.empty(), implementation);
|
||||
}
|
||||
|
||||
@@ -66,7 +63,7 @@ public interface RepositoryFragment<T> {
|
||||
* @param implementation must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
public static <T> RepositoryFragment<T> implemented(Class<T> interfaceClass, T implementation) {
|
||||
static <T> RepositoryFragment<T> implemented(Class<T> interfaceClass, T implementation) {
|
||||
return new ImplementedRepositoryFragment<>(Optional.of(interfaceClass), implementation);
|
||||
}
|
||||
|
||||
@@ -76,7 +73,7 @@ public interface RepositoryFragment<T> {
|
||||
* @param interfaceOrImplementation must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
public static <T> RepositoryFragment<T> structural(Class<T> interfaceOrImplementation) {
|
||||
static <T> RepositoryFragment<T> structural(Class<T> interfaceOrImplementation) {
|
||||
return new StructuralRepositoryFragment<>(interfaceOrImplementation);
|
||||
}
|
||||
|
||||
@@ -122,11 +119,13 @@ public interface RepositoryFragment<T> {
|
||||
*/
|
||||
RepositoryFragment<T> withImplementation(T implementation);
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
static class StructuralRepositoryFragment<T> implements RepositoryFragment<T> {
|
||||
class StructuralRepositoryFragment<T> implements RepositoryFragment<T> {
|
||||
|
||||
private final @NonNull Class<T> interfaceOrImplementation;
|
||||
private final Class<T> interfaceOrImplementation;
|
||||
|
||||
public StructuralRepositoryFragment(Class<T> interfaceOrImplementation) {
|
||||
this.interfaceOrImplementation = interfaceOrImplementation;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -146,17 +145,45 @@ public interface RepositoryFragment<T> {
|
||||
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<T> implements RepositoryFragment<T> {
|
||||
class ImplementedRepositoryFragment<T> implements RepositoryFragment<T> {
|
||||
|
||||
private final Optional<Class<T>> interfaceClass;
|
||||
private final T implementation;
|
||||
@@ -223,5 +250,45 @@ public interface RepositoryFragment<T> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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, Method> METHOD_CACHE = new ConcurrentReferenceHashMap<Method, Method>();
|
||||
@@ -149,6 +147,10 @@ public class ExtensionAwareQueryMethodEvaluationContextProvider implements Query
|
||||
private final Object target;
|
||||
private final Map<String, java.util.function.Function<Object, Object>> 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.
|
||||
|
||||
@@ -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<Object, Object> {
|
||||
|
||||
private final @NonNull Class<?> targetType;
|
||||
private final @NonNull Converter<Object, Object> delegate;
|
||||
private final Class<?> targetType;
|
||||
private final Converter<Object, Object> delegate;
|
||||
|
||||
private ChainingConverter(Class<?> targetType, Converter<Object, Object> delegate) {
|
||||
this.targetType = targetType;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public static ChainingConverter of(Class<?> targetType, Converter<Object, Object> 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<Object, Object> {
|
||||
|
||||
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}.
|
||||
*
|
||||
|
||||
@@ -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<CacheKey, ReturnedType> 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() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
* <code>(index, spel) -> "__some_placeholder_" + index</code>
|
||||
*/
|
||||
private final @NonNull BiFunction<Integer, String, String> parameterNameSource;
|
||||
private final BiFunction<Integer, String, String> 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 <code>(prefix, name) -> prefix + name</code> or
|
||||
* <code>(prefix, name) -> "{" + name + "}"</code>
|
||||
*/
|
||||
private final @NonNull BiFunction<String, String, String> replacementSource;
|
||||
private final BiFunction<String, String, String> replacementSource;
|
||||
|
||||
private SpelQueryContext(BiFunction<Integer, String, String> parameterNameSource,
|
||||
BiFunction<String, String, String> 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<Integer, String, String> parameterNameSource,
|
||||
BiFunction<String, String, String> replacementSource) {
|
||||
return new SpelQueryContext(parameterNameSource, replacementSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the query for SpEL expressions using the pattern:
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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<OrPart> {
|
||||
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<OrPart> {
|
||||
private static final String ORDER_BY = "OrderBy";
|
||||
|
||||
private final List<OrPart> 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<OrPart> {
|
||||
return predicate;
|
||||
}
|
||||
|
||||
public OrderBySource getOrderBySource() {
|
||||
return orderBySource;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
|
||||
@@ -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<? extends Annotation> annotationType;
|
||||
private final @NonNull Optional<String> attributeName;
|
||||
private final Class<? extends Annotation> annotationType;
|
||||
private final Optional<String> 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<? extends Annotation> annotationType, Optional<String> 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.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Class<?>> wrapperTypes;
|
||||
private final ConversionService conversionService;
|
||||
private final Object nullValue;
|
||||
private final Iterable<Class<?>> 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<Class<?>> wrapperTypes) {
|
||||
this.conversionService = conversionService;
|
||||
this.nullValue = nullValue;
|
||||
this.wrapperTypes = wrapperTypes;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.core.convert.converter.GenericConverter#getConvertibleTypes()
|
||||
*/
|
||||
@Nonnull
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> 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<TypeDescriptor, Boolean> 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<ConvertiblePair> 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);
|
||||
|
||||
@@ -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<ReactiveTypeWrapper<?>> 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<T> {
|
||||
private static interface ReactiveTypeWrapper<T> {
|
||||
|
||||
/**
|
||||
* @return the wrapper class.
|
||||
@@ -219,7 +219,7 @@ public class ReactiveWrapperConverters {
|
||||
/**
|
||||
* Wrapper for Project Reactor's {@link Mono}.
|
||||
*/
|
||||
private enum MonoWrapper implements ReactiveTypeWrapper<Mono<?>> {
|
||||
private static enum MonoWrapper implements ReactiveTypeWrapper<Mono<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -237,7 +237,7 @@ public class ReactiveWrapperConverters {
|
||||
/**
|
||||
* Wrapper for Project Reactor's {@link Flux}.
|
||||
*/
|
||||
private enum FluxWrapper implements ReactiveTypeWrapper<Flux<?>> {
|
||||
private static enum FluxWrapper implements ReactiveTypeWrapper<Flux<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -254,7 +254,7 @@ public class ReactiveWrapperConverters {
|
||||
/**
|
||||
* Wrapper for Reactive Stream's {@link Publisher}.
|
||||
*/
|
||||
private enum PublisherWrapper implements ReactiveTypeWrapper<Publisher<?>> {
|
||||
private static enum PublisherWrapper implements ReactiveTypeWrapper<Publisher<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -281,7 +281,7 @@ public class ReactiveWrapperConverters {
|
||||
/**
|
||||
* Wrapper for RxJava 1's {@link Single}.
|
||||
*/
|
||||
private enum RxJava1SingleWrapper implements ReactiveTypeWrapper<Single<?>> {
|
||||
private static enum RxJava1SingleWrapper implements ReactiveTypeWrapper<Single<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -299,7 +299,7 @@ public class ReactiveWrapperConverters {
|
||||
/**
|
||||
* Wrapper for RxJava 1's {@link Observable}.
|
||||
*/
|
||||
private enum RxJava1ObservableWrapper implements ReactiveTypeWrapper<Observable<?>> {
|
||||
private static enum RxJava1ObservableWrapper implements ReactiveTypeWrapper<Observable<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -317,7 +317,7 @@ public class ReactiveWrapperConverters {
|
||||
/**
|
||||
* Wrapper for RxJava 2's {@link io.reactivex.Single}.
|
||||
*/
|
||||
private enum RxJava2SingleWrapper implements ReactiveTypeWrapper<io.reactivex.Single<?>> {
|
||||
private static enum RxJava2SingleWrapper implements ReactiveTypeWrapper<io.reactivex.Single<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -335,7 +335,7 @@ public class ReactiveWrapperConverters {
|
||||
/**
|
||||
* Wrapper for RxJava 2's {@link io.reactivex.Maybe}.
|
||||
*/
|
||||
private enum RxJava2MaybeWrapper implements ReactiveTypeWrapper<Maybe<?>> {
|
||||
private static enum RxJava2MaybeWrapper implements ReactiveTypeWrapper<Maybe<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -353,7 +353,7 @@ public class ReactiveWrapperConverters {
|
||||
/**
|
||||
* Wrapper for RxJava 2's {@link io.reactivex.Observable}.
|
||||
*/
|
||||
private enum RxJava2ObservableWrapper implements ReactiveTypeWrapper<io.reactivex.Observable<?>> {
|
||||
private static enum RxJava2ObservableWrapper implements ReactiveTypeWrapper<io.reactivex.Observable<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -371,7 +371,7 @@ public class ReactiveWrapperConverters {
|
||||
/**
|
||||
* Wrapper for RxJava 2's {@link io.reactivex.Flowable}.
|
||||
*/
|
||||
private enum RxJava2FlowableWrapper implements ReactiveTypeWrapper<Flowable<?>> {
|
||||
private static enum RxJava2FlowableWrapper implements ReactiveTypeWrapper<Flowable<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -396,7 +396,7 @@ public class ReactiveWrapperConverters {
|
||||
* @author Mark Paluch
|
||||
* @author 2.0
|
||||
*/
|
||||
private enum PublisherToFluxConverter implements Converter<Publisher<?>, Flux<?>> {
|
||||
private static enum PublisherToFluxConverter implements Converter<Publisher<?>, Flux<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -413,7 +413,7 @@ public class ReactiveWrapperConverters {
|
||||
* @author Mark Paluch
|
||||
* @author 2.0
|
||||
*/
|
||||
private enum PublisherToMonoConverter implements Converter<Publisher<?>, Mono<?>> {
|
||||
private static enum PublisherToMonoConverter implements Converter<Publisher<?>, Mono<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -434,7 +434,7 @@ public class ReactiveWrapperConverters {
|
||||
* @author Mark Paluch
|
||||
* @author 2.3
|
||||
*/
|
||||
private enum PublisherToFlowConverter implements Converter<Publisher<?>, Flow<?>> {
|
||||
private static enum PublisherToFlowConverter implements Converter<Publisher<?>, 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<Object, Object>, ConditionalConverter {
|
||||
private static enum ReactiveAdapterConverterFactory
|
||||
implements ConverterFactory<Object, Object>, ConditionalConverter {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String, Object> getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public MultiValueMap<String, Function> 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)
|
||||
|
||||
@@ -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<Class<?>, EvaluationContextExtensionInformation> extensionInformationCache = new ConcurrentHashMap<>();
|
||||
@@ -95,6 +91,11 @@ public class ExtensionAwareEvaluationContextProvider implements EvaluationContex
|
||||
this(Lazy.of(extensions));
|
||||
}
|
||||
|
||||
public ExtensionAwareEvaluationContextProvider(
|
||||
Lazy<? extends Collection<? extends EvaluationContextExtension>> 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)
|
||||
|
||||
@@ -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}.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<T> implements Supplier<T> {
|
||||
|
||||
private static final Lazy<?> EMPTY = new Lazy<>(() -> null, null, true);
|
||||
|
||||
private final Supplier<? extends T> supplier;
|
||||
|
||||
private @Nullable T value = null;
|
||||
private boolean resolved = false;
|
||||
|
||||
public Lazy(Supplier<? extends T> supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
private Lazy(Supplier<? extends T> 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<T> implements Supplier<T> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T> implements Streamable<T> {
|
||||
final class LazyStreamable<T> implements Streamable<T> {
|
||||
|
||||
private final Supplier<? extends Stream<T>> stream;
|
||||
|
||||
private LazyStreamable(Supplier<? extends Stream<T>> stream) {
|
||||
this.stream = stream;
|
||||
}
|
||||
|
||||
public static <T> LazyStreamable<T> of(Supplier<? extends Stream<T>> stream) {
|
||||
return new LazyStreamable<T>(stream);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
@@ -49,4 +54,17 @@ class LazyStreamable<T> implements Streamable<T> {
|
||||
public Stream<T> stream() {
|
||||
return stream.get();
|
||||
}
|
||||
|
||||
public Supplier<? extends Stream<T>> getStream() {
|
||||
return this.stream;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LazyStreamable(stream=" + this.getStream() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<RecordingMethodInterceptor> 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<T> {
|
||||
|
||||
private final @Nullable T currentInstance;
|
||||
private final @Nullable MethodInvocationRecorder recorder;
|
||||
|
||||
public Recorded(T currentInstance, MethodInvocationRecorder recorder) {
|
||||
this.currentInstance = currentInstance;
|
||||
this.recorder = recorder;
|
||||
}
|
||||
|
||||
public Optional<String> getPropertyPath() {
|
||||
return getPropertyPath(MethodInvocationRecorder.DEFAULT);
|
||||
}
|
||||
@@ -304,6 +361,16 @@ public class MethodInvocationRecorder {
|
||||
return new Recorded<S>(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<T, S> extends Function<T, Collection<S>> {}
|
||||
|
||||
public interface ToMapConverter<T, S> extends Function<T, Map<?, S>> {}
|
||||
|
||||
@@ -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<T, K, V> implements Collector<T, MultiValueMap<K, V>, MultiValueMap<K, V>> {
|
||||
|
||||
private final @NonNull Function<T, K> keyFunction;
|
||||
private final @NonNull Function<T, V> valueFunction;
|
||||
private final Function<T, K> keyFunction;
|
||||
private final Function<T, V> valueFunction;
|
||||
|
||||
private MultiValueMapCollector(Function<T, K> keyFunction, Function<T, V> valueFunction) {
|
||||
this.keyFunction = keyFunction;
|
||||
this.valueFunction = valueFunction;
|
||||
}
|
||||
|
||||
static <T, K, V> MultiValueMapCollector<T, K, V> of(Function<T, K> keyFunction, Function<T, V> valueFunction) {
|
||||
return new MultiValueMapCollector<T, K, V>(keyFunction, valueFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -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<String> WHEN_NULLABLE = new HashSet<>(Arrays.asList("UNKNOWN", "MAYBE", "NEVER"));
|
||||
private static final Set<String> 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()) {
|
||||
|
||||
|
||||
@@ -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 <T> Type of the second thing.
|
||||
* @since 1.12
|
||||
*/
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class Pair<S, T> {
|
||||
|
||||
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<S, T> {
|
||||
public static <S, T> Collector<Pair<S, T>, ?, Map<S, T>> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<TypeDescriptor> types, Lazy<Collection<ParameterTypes>> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}.
|
||||
*
|
||||
|
||||
@@ -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<?>, 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
|
||||
*/
|
||||
|
||||
@@ -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<? extends Annotation> annotationType;
|
||||
private final Class<? extends Annotation> annotationType;
|
||||
|
||||
public AnnotationFieldFilter(Class<? extends Annotation> annotationType) {
|
||||
this.annotationType = annotationType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -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<S> implements TypeInformation<S> {
|
||||
* @author Oliver Gierke
|
||||
* @since 1.11
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@RequiredArgsConstructor
|
||||
private static class SyntheticParamterizedType implements ParameterizedType {
|
||||
|
||||
private final @NonNull ClassTypeInformation<?> typeInformation;
|
||||
private final @NonNull List<TypeInformation<?>> typeParameters;
|
||||
private final ClassTypeInformation<?> typeInformation;
|
||||
private final List<TypeInformation<?>> typeParameters;
|
||||
|
||||
public SyntheticParamterizedType(ClassTypeInformation<?> typeInformation, List<TypeInformation<?>> typeParameters) {
|
||||
this.typeInformation = typeInformation;
|
||||
this.typeParameters = typeParameters;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -614,5 +623,40 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Object> {
|
||||
|
||||
private final ResolvableType type;
|
||||
|
||||
ResolvableTypeRef(ResolvableType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.jayway.jsonpath.TypeRef#getType()
|
||||
|
||||
@@ -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<String, Object> 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<String, Object> map;
|
||||
private final @NonNull ConversionService conversionService;
|
||||
private final Class<?> type;
|
||||
private final Map<String, Object> map;
|
||||
private final ConversionService conversionService;
|
||||
|
||||
public MapPropertyAccessor(Class<?> type, Map<String, Object> map, ConversionService conversionService) {
|
||||
|
||||
this.type = type;
|
||||
this.map = map;
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
Reference in New Issue
Block a user