Skip to content

Commit 5e2c751

Browse files
committed
Remove @Deprecated API.
Closes #3208
1 parent 542d928 commit 5e2c751

File tree

70 files changed

+90
-3048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+90
-3048
lines changed

src/main/java/org/springframework/data/annotation/PersistenceConstructor.java

-35
This file was deleted.

src/main/java/org/springframework/data/geo/Circle.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.data.geo;
1717

18-
import org.springframework.data.annotation.PersistenceConstructor;
18+
import org.springframework.data.annotation.PersistenceCreator;
1919
import org.springframework.util.Assert;
2020
import org.springframework.util.ObjectUtils;
2121

@@ -40,7 +40,7 @@ public class Circle implements Shape {
4040
* @param center must not be {@literal null}.
4141
* @param radius must not be {@literal null} and it's value greater or equal to zero.
4242
*/
43-
@PersistenceConstructor
43+
@PersistenceCreator
4444
public Circle(Point center, Distance radius) {
4545

4646
Assert.notNull(center, "Center point must not be null");

src/main/java/org/springframework/data/geo/GeoResults.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Iterator;
2222
import java.util.List;
2323

24-
import org.springframework.data.annotation.PersistenceConstructor;
24+
import org.springframework.data.annotation.PersistenceCreator;
2525
import org.springframework.util.Assert;
2626
import org.springframework.util.ObjectUtils;
2727
import org.springframework.util.StringUtils;
@@ -67,7 +67,7 @@ public GeoResults(List<? extends GeoResult<T>> results, Metric metric) {
6767
* @param results must not be {@literal null}.
6868
* @param averageDistance must not be {@literal null}.
6969
*/
70-
@PersistenceConstructor
70+
@PersistenceCreator
7171
public GeoResults(List<? extends GeoResult<T>> results, Distance averageDistance) {
7272

7373
Assert.notNull(results, "Results must not be null");

src/main/java/org/springframework/data/geo/Point.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.io.Serializable;
1919
import java.util.Locale;
2020

21-
import org.springframework.data.annotation.PersistenceConstructor;
21+
import org.springframework.data.annotation.PersistenceCreator;
2222
import org.springframework.lang.Nullable;
2323
import org.springframework.util.Assert;
2424

@@ -43,7 +43,7 @@ public class Point implements Serializable {
4343
* @param x
4444
* @param y
4545
*/
46-
@PersistenceConstructor
46+
@PersistenceCreator
4747
public Point(double x, double y) {
4848
this.x = x;
4949
this.y = y;

src/main/java/org/springframework/data/geo/Polygon.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.util.Iterator;
2323
import java.util.List;
2424

25-
import org.springframework.data.annotation.PersistenceConstructor;
25+
import org.springframework.data.annotation.PersistenceCreator;
2626
import org.springframework.util.Assert;
2727
import org.springframework.util.ObjectUtils;
2828
import org.springframework.util.StringUtils;
@@ -67,7 +67,7 @@ public Polygon(Point x, Point y, Point z, Point... others) {
6767
*
6868
* @param points must not be {@literal null}.
6969
*/
70-
@PersistenceConstructor
70+
@PersistenceCreator
7171
public Polygon(List<? extends Point> points) {
7272

7373
Assert.notNull(points, "Points must not be null");

src/main/java/org/springframework/data/mapping/Parameter.java

-12
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ public Class<T> getRawType() {
131131
* Returns the expression to be used when looking up a source data structure to populate the actual parameter value.
132132
*
133133
* @return the expression to be used when looking up a source data structure.
134-
* @deprecated since 3.3, use {@link #getValueExpression()} instead.
135134
*/
136135
@Nullable
137136
public String getSpelExpression() {
@@ -165,17 +164,6 @@ public String getRequiredValueExpression() {
165164
return getValueExpression();
166165
}
167166

168-
/**
169-
* Returns whether the constructor parameter is equipped with a SpEL expression.
170-
*
171-
* @return {@literal true}} if the parameter is equipped with a SpEL expression.
172-
* @deprecated since 3.3, use {@link #hasValueExpression()} instead.
173-
*/
174-
@Deprecated(since = "3.3")
175-
public boolean hasSpelExpression() {
176-
return hasValueExpression();
177-
}
178-
179167
/**
180168
* Returns whether the constructor parameter is equipped with a value expression.
181169
*

src/main/java/org/springframework/data/mapping/PersistentEntity.java

-27
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,6 @@ public interface PersistentEntity<T, P extends PersistentProperty<P>> extends It
4343
*/
4444
String getName();
4545

46-
/**
47-
* Returns the {@link PreferredConstructor} to be used to instantiate objects of this {@link PersistentEntity}.
48-
*
49-
* @return {@literal null} in case no suitable constructor for automatic construction can be found. This usually
50-
* indicates that the instantiation of the object of that persistent entity is done through either a
51-
* customer {@link org.springframework.data.mapping.model.EntityInstantiator} or handled by custom
52-
* conversion mechanisms entirely.
53-
* @deprecated since 3.0, use {@link #getInstanceCreatorMetadata()}.
54-
*/
55-
@Nullable
56-
@Deprecated
57-
PreferredConstructor<T, P> getPersistenceConstructor();
58-
5946
/**
6047
* Returns the {@link InstanceCreatorMetadata} to be used to instantiate objects of this {@link PersistentEntity}.
6148
*
@@ -68,20 +55,6 @@ public interface PersistentEntity<T, P extends PersistentProperty<P>> extends It
6855
@Nullable
6956
InstanceCreatorMetadata<P> getInstanceCreatorMetadata();
7057

71-
/**
72-
* Returns whether the given {@link PersistentProperty} is referred to by a constructor argument of the
73-
* {@link PersistentEntity}.
74-
*
75-
* @param property can be {@literal null}.
76-
* @return true if the given {@link PersistentProperty} is referred to by a constructor argument or {@literal false}
77-
* if not or {@literal null}.
78-
* @deprecated since 3.0, use {@link #isCreatorArgument(PersistentProperty)} instead.
79-
*/
80-
@Deprecated
81-
default boolean isConstructorArgument(PersistentProperty<?> property) {
82-
return isCreatorArgument(property);
83-
}
84-
8558
/**
8659
* Returns whether the given {@link PersistentProperty} is referred to by a creator argument of the
8760
* {@link PersistentEntity}.

src/main/java/org/springframework/data/mapping/PersistentPropertyPath.java

-13
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,6 @@ public interface PersistentPropertyPath<P extends PersistentProperty<P>> extends
7070
*/
7171
P getLeafProperty();
7272

73-
/**
74-
* Returns the last property in the {@link PersistentPropertyPath}. So for {@code foo.bar} it will return the
75-
* {@link PersistentProperty} for {@code bar}. For a simple {@code foo} it returns {@link PersistentProperty} for
76-
* {@code foo}.
77-
*
78-
* @return will never be {@literal null}.
79-
* @deprecated use {@link #getLeafProperty()} instead.
80-
*/
81-
@Deprecated(since = "3.1", forRemoval = true)
82-
default P getRequiredLeafProperty() {
83-
return getLeafProperty();
84-
}
85-
8673
/**
8774
* Returns the first property in the {@link PersistentPropertyPath}. So for {@code foo.bar} it will return the
8875
* {@link PersistentProperty} for {@code foo}. For a simple {@code foo} it returns {@link PersistentProperty} for

src/main/java/org/springframework/data/mapping/PreferredConstructor.java

+3-16
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.List;
2121

2222
import org.springframework.core.annotation.MergedAnnotations;
23-
import org.springframework.data.annotation.PersistenceConstructor;
2423
import org.springframework.data.annotation.PersistenceCreator;
2524
import org.springframework.util.Assert;
2625
import org.springframework.util.ReflectionUtils;
@@ -36,7 +35,6 @@
3635
* @author Myeonghyeon Lee
3736
* @author Xeno Amess
3837
*/
39-
@SuppressWarnings("deprecation")
4038
public final class PreferredConstructor<T, P extends PersistentProperty<P>>
4139
extends InstanceCreatorMetadataSupport<T, P> {
4240

@@ -78,26 +76,15 @@ public boolean isNoArgConstructor() {
7876
}
7977

8078
/**
81-
* Returns whether the constructor was explicitly selected (by {@link PersistenceConstructor}).
79+
* Returns whether the constructor was explicitly selected (by {@link PersistenceCreator}).
8280
*
83-
* @return
81+
* @return {@literal true} if the constructor was explicitly selected.
8482
*/
8583
public boolean isExplicitlyAnnotated() {
8684

8785
var annotations = MergedAnnotations.from(getExecutable());
8886

89-
return annotations.isPresent(PersistenceConstructor.class)
90-
|| annotations.isPresent(PersistenceCreator.class);
91-
}
92-
93-
/**
94-
* @param property
95-
* @return
96-
* @deprecated since 3.0, use {@link #isCreatorParameter(PersistentProperty)} instead.
97-
*/
98-
@Deprecated
99-
public boolean isConstructorParameter(PersistentProperty<?> property) {
100-
return isCreatorParameter(property);
87+
return annotations.isPresent(PersistenceCreator.class);
10188
}
10289

10390
@Override

src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java

-7
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,6 @@ public BasicPersistentEntity(TypeInformation<T> information, @Nullable Comparato
130130
.anyMatch(it -> !(isCreatorArgument(it) || it.isTransient())));
131131
}
132132

133-
@Nullable
134-
@Override
135-
@SuppressWarnings("unchecked")
136-
public PreferredConstructor<T, P> getPersistenceConstructor() {
137-
return creator instanceof PreferredConstructor ? (PreferredConstructor<T, P>) creator : null;
138-
}
139-
140133
@Nullable
141134
@Override
142135
public InstanceCreatorMetadata<P> getInstanceCreatorMetadata() {

src/main/java/org/springframework/data/mapping/model/ClassGeneratingEntityInstantiator.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.asm.Opcodes;
3333
import org.springframework.asm.Type;
3434
import org.springframework.beans.BeanInstantiationException;
35+
import org.springframework.beans.BeanUtils;
3536
import org.springframework.cglib.core.ReflectUtils;
3637
import org.springframework.core.NativeDetector;
3738
import org.springframework.data.mapping.FactoryMethod;
@@ -159,8 +160,7 @@ private EntityInstantiator createEntityInstantiator(PersistentEntity<?, ?> entit
159160
* @return
160161
*/
161162
protected EntityInstantiator doCreateEntityInstantiator(PersistentEntity<?, ?> entity) {
162-
return new EntityInstantiatorAdapter(
163-
createObjectInstantiator(entity, entity.getInstanceCreatorMetadata()));
163+
return new EntityInstantiatorAdapter(createObjectInstantiator(entity, entity.getInstanceCreatorMetadata()));
164164
}
165165

166166
/**
@@ -239,7 +239,8 @@ ObjectInstantiator createObjectInstantiator(PersistentEntity<?, ?> entity,
239239
@Nullable InstanceCreatorMetadata<?> constructor) {
240240

241241
try {
242-
return (ObjectInstantiator) this.generator.generateCustomInstantiatorClass(entity, constructor).newInstance();
242+
Class<?> instantiatorClass = this.generator.generateCustomInstantiatorClass(entity, constructor);
243+
return (ObjectInstantiator) BeanUtils.instantiateClass(instantiatorClass);
243244
} catch (Exception e) {
244245
throw new RuntimeException(e);
245246
}
@@ -482,8 +483,7 @@ private void visitCreateMethod(ClassWriter cw, PersistentEntity<?, ?> entity,
482483
String entityTypeResourcePath = Type.getInternalName(entity.getType());
483484

484485
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC + ACC_VARARGS, CREATE_METHOD_NAME,
485-
"([" + BytecodeUtil.referenceName(Object.class) + ")" + BytecodeUtil.referenceName(Object.class),
486-
null, null);
486+
"([" + BytecodeUtil.referenceName(Object.class) + ")" + BytecodeUtil.referenceName(Object.class), null, null);
487487
mv.visitCode();
488488
mv.visitTypeInsn(NEW, entityTypeResourcePath);
489489
mv.visitInsn(DUP);

src/main/java/org/springframework/data/mapping/model/DefaultSpELExpressionEvaluator.java

-56
This file was deleted.

src/main/java/org/springframework/data/mapping/model/MappingInstantiationException.java

-12
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,6 @@ public Optional<Class<?>> getEntityType() {
155155
return Optional.ofNullable(entityType);
156156
}
157157

158-
/**
159-
* The constructor used during the instantiation attempt.
160-
*
161-
* @return the constructor
162-
* @deprecated since 3.0, use {@link #getEntityCreator()} instead.
163-
*/
164-
@Deprecated
165-
public Optional<Constructor<?>> getConstructor() {
166-
return getEntityCreator().filter(PreferredConstructor.class::isInstance).map(PreferredConstructor.class::cast)
167-
.map(PreferredConstructor::getConstructor);
168-
}
169-
170158
/**
171159
* The entity creator used during the instantiation attempt.
172160
*

src/main/java/org/springframework/data/mapping/model/PersistentEntityParameterValueProvider.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424

2525
/**
2626
* {@link ParameterValueProvider} based on a {@link PersistentEntity} to use a {@link PropertyValueProvider} to lookup
27-
* the value of the property referenced by the given {@link Parameter}. Additionally a
28-
* {@link DefaultSpELExpressionEvaluator} can be configured to get property value resolution trumped by a SpEL
29-
* expression evaluation.
27+
* the value of the property referenced by the given {@link Parameter}.
3028
*
3129
* @author Oliver Gierke
3230
* @author Johannes Englmeier

0 commit comments

Comments
 (0)