DATACMNS-1726 - Delombok source files.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user