Skip to content

Commit d991ca1

Browse files
committed
Remove @Deprecated API.
See #3208
1 parent f8533d0 commit d991ca1

File tree

9 files changed

+6
-432
lines changed

9 files changed

+6
-432
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.data.mapping.Association;
2828
import org.springframework.data.mapping.PersistentEntity;
2929
import org.springframework.data.mapping.PersistentProperty;
30+
import org.springframework.data.util.ClassUtils;
3031
import org.springframework.data.util.KotlinReflectionUtils;
3132
import org.springframework.data.util.Lazy;
3233
import org.springframework.data.util.ReflectionUtils;
@@ -50,7 +51,7 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
5051
static {
5152

5253
CAUSE_FIELD = ReflectionUtils.getRequiredField(Throwable.class, "cause");
53-
ASSOCIATION_TYPE = ReflectionUtils.loadIfPresent("org.jmolecules.ddd.types.Association",
54+
ASSOCIATION_TYPE = ClassUtils.loadIfPresent("org.jmolecules.ddd.types.Association",
5455
AbstractPersistentProperty.class.getClassLoader());
5556
}
5657

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
import org.springframework.data.mapping.MappingException;
3838
import org.springframework.data.mapping.PersistentEntity;
3939
import org.springframework.data.mapping.PersistentProperty;
40+
import org.springframework.data.util.ClassUtils;
4041
import org.springframework.data.util.Lazy;
4142
import org.springframework.data.util.Optionals;
42-
import org.springframework.data.util.ReflectionUtils;
4343
import org.springframework.data.util.StreamUtils;
4444
import org.springframework.data.util.TypeInformation;
4545
import org.springframework.lang.Nullable;
@@ -316,7 +316,7 @@ private Stream<? extends AnnotatedElement> getAccessors() {
316316
@SuppressWarnings("unchecked")
317317
private static Class<? extends Annotation> loadIdentityType() {
318318

319-
return (Class<? extends Annotation>) ReflectionUtils.loadIfPresent("org.jmolecules.ddd.annotation.Identity",
319+
return (Class<? extends Annotation>) ClassUtils.loadIfPresent("org.jmolecules.ddd.annotation.Identity",
320320
AbstractPersistentProperty.class.getClassLoader());
321321
}
322322
}

src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java

-2
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,11 @@ private static boolean shouldExposeMetadata(RepositoryFragments fragments) {
659659
*/
660660
static class ImplementationMethodExecutionInterceptor implements MethodInterceptor {
661661

662-
private final RepositoryInformation information;
663662
private final RepositoryComposition composition;
664663
private final RepositoryInvocationMulticaster invocationMulticaster;
665664

666665
public ImplementationMethodExecutionInterceptor(RepositoryInformation information,
667666
RepositoryComposition composition, List<RepositoryMethodInvocationListener> methodInvocationListeners) {
668-
this.information = information;
669667
this.composition = composition;
670668
this.invocationMulticaster = methodInvocationListeners.isEmpty() ? NoOpRepositoryInvocationMulticaster.INSTANCE
671669
: new DefaultRepositoryInvocationMulticaster(methodInvocationListeners);

src/main/java/org/springframework/data/repository/util/ClassUtils.java

-204
This file was deleted.

src/main/java/org/springframework/data/util/CastUtils.java

-28
This file was deleted.

src/main/java/org/springframework/data/util/ReflectionUtils.java

-64
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.stream.Collectors;
2929
import java.util.stream.Stream;
3030

31-
import org.springframework.beans.BeanUtils;
3231
import org.springframework.core.KotlinDetector;
3332
import org.springframework.core.MethodParameter;
3433
import org.springframework.core.ResolvableType;
@@ -98,27 +97,6 @@ public static int getParameterCount(Method method, Predicate<Class<?>> predicate
9897
return (int) Arrays.stream(method.getParameterTypes()).filter(predicate).count();
9998
}
10099

101-
/**
102-
* Creates an instance of the class with the given fully qualified name or returns the given default instance if the
103-
* class cannot be loaded or instantiated.
104-
*
105-
* @param classname the fully qualified class name to create an instance for.
106-
* @param defaultInstance the instance to fall back to in case the given class cannot be loaded or instantiated.
107-
* @return
108-
* @deprecated since 3.5 as it is not used within the framework anymore.
109-
*/
110-
@SuppressWarnings("unchecked")
111-
@Deprecated(since = "3.5", forRemoval = true)
112-
public static <T> T createInstanceIfPresent(String classname, T defaultInstance) {
113-
114-
try {
115-
Class<?> type = ClassUtils.forName(classname, ClassUtils.getDefaultClassLoader());
116-
return (T) BeanUtils.instantiateClass(type);
117-
} catch (Exception e) {
118-
return defaultInstance;
119-
}
120-
}
121-
122100
/**
123101
* Check whether the given {@code type} represents a void type such as {@code void}, {@link Void} or Kotlin
124102
* {@code Unit}.
@@ -264,20 +242,6 @@ public static Field findField(Class<?> type, DescribedFieldFilter filter, boolea
264242
return foundField;
265243
}
266244

267-
/**
268-
* Finds the field of the given name on the given type.
269-
*
270-
* @param type must not be {@literal null}.
271-
* @param name must not be {@literal null} or empty.
272-
* @return the required field.
273-
* @throws IllegalArgumentException in case the field can't be found.
274-
* @deprecated use {@link #getRequiredField(Class, String)} instead.
275-
*/
276-
@Deprecated(since = "3.5", forRemoval = true)
277-
public static Field findRequiredField(Class<?> type, String name) {
278-
return getRequiredField(type, name);
279-
}
280-
281245
/**
282246
* Obtains the required field of the given name on the given type or throws {@link IllegalArgumentException} if the
283247
* found could not be found.
@@ -411,20 +375,6 @@ public static Stream<Class<?>> returnTypeAndParameters(Method method) {
411375
return Stream.concat(returnType, parameterTypes);
412376
}
413377

414-
/**
415-
* Returns the {@link Method} with the given name and parameters declared on the given type, if available.
416-
*
417-
* @param type must not be {@literal null}.
418-
* @param name must not be {@literal null} or empty.
419-
* @param parameterTypes must not be {@literal null}.
420-
* @return the optional Method.
421-
* @since 2.0
422-
*/
423-
@Deprecated(since = "3.5", forRemoval = true)
424-
public static Optional<Method> getMethod(Class<?> type, String name, ResolvableType... parameterTypes) {
425-
return Optional.ofNullable(findMethod(type, name, parameterTypes));
426-
}
427-
428378
/**
429379
* Returns the {@link Method} with the given name and parameters declared on the given type, if available.
430380
*
@@ -557,18 +507,4 @@ public static Object getPrimitiveDefault(Class<?> type) {
557507
throw new IllegalArgumentException(String.format("Primitive type %s not supported", type));
558508
}
559509

560-
/**
561-
* Loads the class with the given name using the given {@link ClassLoader}.
562-
*
563-
* @param name the name of the class to be loaded.
564-
* @param classLoader the {@link ClassLoader} to use to load the class.
565-
* @return the {@link Class} or {@literal null} in case the class can't be loaded for any reason.
566-
* @since 2.5
567-
*/
568-
@Nullable
569-
@Deprecated(since = "3.5", forRemoval = true)
570-
public static Class<?> loadIfPresent(String name, ClassLoader classLoader) {
571-
return org.springframework.data.util.ClassUtils.loadIfPresent(name, classLoader);
572-
}
573-
574510
}

0 commit comments

Comments
 (0)