Skip to content

Commit

Permalink
Remove almost all deprecated methods from (Basic)BeanDescription (#4527)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored May 14, 2024
1 parent 04ead23 commit e711d7e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 112 deletions.
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

0 comments on commit e711d7e

Please sign in to comment.