Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove almost all deprecated methods from (Basic)BeanDescription #4527

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.fasterxml.jackson.databind;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.*;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;

import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.fasterxml.jackson.databind.introspect.*;
import com.fasterxml.jackson.databind.type.TypeBindings;
import com.fasterxml.jackson.databind.util.Annotations;
import com.fasterxml.jackson.databind.util.Converter;

Expand Down Expand Up @@ -82,26 +80,6 @@ public boolean isNonStaticInnerClass() {
*/
public abstract boolean hasKnownClassAnnotations();

/**
* Accessor for type bindings that may be needed to fully resolve
* types of member object, such as return and argument types of
* methods and constructors, and types of fields.
*
* @deprecated Since 2.7, should not need to access bindings directly
*/
@Deprecated
public abstract TypeBindings bindingsForBeanType();

/**
* Method for resolving given JDK type, using this bean as the
* generic type resolution context.
*
* @deprecated Since 2.8, should simply call <code>getType</code> of
* property accessor directly.
*/
@Deprecated
public abstract JavaType resolveType(java.lang.reflect.Type jdkType);

/**
* Method for accessing collection of annotations the bean
* class has.
Expand Down Expand Up @@ -129,14 +107,6 @@ public boolean isNonStaticInnerClass() {
*/
public abstract List<BeanPropertyDefinition> findBackReferences();

/**
* Method for locating all back-reference properties (setters, fields) bean has
*
* @deprecated Since 2.9 use {@link #findBackReferences()} instead
*/
@Deprecated
public abstract Map<String,AnnotatedMember> findBackReferenceProperties();

/*
/**********************************************************
/* Basic API for finding creator members
Expand Down Expand Up @@ -196,18 +166,6 @@ public boolean isNonStaticInnerClass() {
*/
public abstract AnnotatedConstructor findDefaultConstructor();

/**
* @deprecated Since 2.13: instead use {@link #getConstructors()}, filter.
*/
@Deprecated
public abstract Constructor<?> findSingleArgConstructor(Class<?>... argTypes);

/**
* @deprecated Since 2.13: instead use {@link #getFactoryMethods()}, filter.
*/
@Deprecated
public abstract Method findFactoryMethod(Class<?>... expArgTypes);

/*
/**********************************************************
/* Basic API for finding property accessors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.fasterxml.jackson.databind.cfg.HandlerInstantiator;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.type.TypeBindings;
import com.fasterxml.jackson.databind.util.Annotations;
import com.fasterxml.jackson.databind.util.ClassUtil;
import com.fasterxml.jackson.databind.util.Converter;
Expand Down Expand Up @@ -271,20 +270,6 @@ public Annotations getClassAnnotations() {
return _classInfo.getAnnotations();
}

@Override
@Deprecated // since 2.7
public TypeBindings bindingsForBeanType() {
return _type.getBindings();
}

@Override
@Deprecated // since 2.8
public JavaType resolveType(java.lang.reflect.Type jdkType) {
// 06-Sep-2020, tatu: Careful wrt [databind#2846][databind#2821],
// call new method added in 2.12
return _config.getTypeFactory().resolveMemberType(jdkType, _type.getBindings());
}

@Override
public AnnotatedConstructor findDefaultConstructor() {
return _classInfo.getDefaultConstructor();
Expand Down Expand Up @@ -521,21 +506,6 @@ public List<BeanPropertyDefinition> findBackReferences()
return result;
}

@Deprecated // since 2.9
@Override
public Map<String,AnnotatedMember> findBackReferenceProperties()
{
List<BeanPropertyDefinition> props = findBackReferences();
if (props == null) {
return null;
}
Map<String,AnnotatedMember> result = new HashMap<>();
for (BeanPropertyDefinition prop : props) {
result.put(prop.getName(), prop.getMutator());
}
return result;
}

/*
/**********************************************************
/* Introspection for deserialization, factories
Expand Down Expand Up @@ -589,45 +559,6 @@ public List<AnnotatedAndMetadata<AnnotatedMethod, JsonCreator.Mode>> getFactoryM
return result;
}

@Override
@Deprecated // since 2.13
public Constructor<?> findSingleArgConstructor(Class<?>... argTypes)
{
for (AnnotatedConstructor ac : _classInfo.getConstructors()) {
// This list is already filtered to only include accessible
if (ac.getParameterCount() == 1) {
Class<?> actArg = ac.getRawParameterType(0);
for (Class<?> expArg : argTypes) {
if (expArg == actArg) {
return ac.getAnnotated();
}
}
}
}
return null;
}

@Override
@Deprecated // since 2.13
public Method findFactoryMethod(Class<?>... expArgTypes)
{
// So, of all single-arg static methods:
for (AnnotatedMethod am : _classInfo.getFactoryMethods()) {
// 24-Oct-2016, tatu: Better ensure it only takes 1 arg, no matter what
if (isFactoryMethod(am) && am.getParameterCount() == 1) {
// And must take one of expected arg types (or supertype)
Class<?> actualArgType = am.getRawParameterType(0);
for (Class<?> expArgType : expArgTypes) {
// And one that matches what we would pass in
if (actualArgType.isAssignableFrom(expArgType)) {
return am.getAnnotated();
}
}
}
}
return null;
}

protected boolean isFactoryMethod(AnnotatedMethod am)
{
// First: return type must be compatible with the introspected class
Expand Down