Skip to content

Commit 20d8d0c

Browse files
committed
Minor clean up to prepare for #3143 fix
1 parent 4430918 commit 20d8d0c

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/main/java/com/fasterxml/jackson/databind/BeanDescription.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,24 @@ public boolean isNonStaticInnerClass() {
139139

140140
public abstract List<AnnotatedConstructor> getConstructors();
141141

142+
/**
143+
* Helper method that will check all static methods of the bean class
144+
* that seem like factory methods eligible to be used as Creators.
145+
* This requires that the static method:
146+
*<ol>
147+
* <li>Returns type compatible with bean type (same or subtype)
148+
* </li>
149+
* <li>Is recognized from either explicit annotation (usually {@code @JsonCreator}
150+
* OR naming:
151+
* names {@code valueOf()} and {@code fromString()} are recognized but
152+
* only for 1-argument factory methods, and in case of {@code fromString()}
153+
* argument type must further be either {@code String} or {@code CharSequence}.
154+
* </li>
155+
*</ol>
156+
* Note that caller typically applies further checks for things like visibility.
157+
*
158+
* @return List of static methods considered as possible Factory methods
159+
*/
142160
public abstract List<AnnotatedMethod> getFactoryMethods();
143161

144162
/**
@@ -149,22 +167,15 @@ public boolean isNonStaticInnerClass() {
149167
public abstract AnnotatedConstructor findDefaultConstructor();
150168

151169
/**
152-
* Method that can be called to locate a single-arg constructor that
153-
* takes specified exact type (will not accept supertype constructors)
154-
*
155-
* @param argTypes Type(s) of the argument that we are looking for
170+
* @deprecated Since 2.13: instead use {@link #getConstructors()}, filter.
156171
*/
172+
@Deprecated
157173
public abstract Constructor<?> findSingleArgConstructor(Class<?>... argTypes);
158174

159175
/**
160-
* Method that can be called to find if introspected class declares
161-
* a static "valueOf" factory method that returns an instance of
162-
* introspected type, given one of acceptable types.
163-
*
164-
* @param expArgTypes Types that the matching single argument factory
165-
* method can take: will also accept super types of these types
166-
* (ie. arg just has to be assignable from expArgType)
176+
* @deprecated Since 2.13: instead use {@link #getFactoryMethods()}, filter.
167177
*/
178+
@Deprecated
168179
public abstract Method findFactoryMethod(Class<?>... expArgTypes);
169180

170181
/*

src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,11 @@ public List<AnnotatedMethod> getFactoryMethods()
572572
}
573573

574574
@Override
575+
@Deprecated // since 2.13
575576
public Constructor<?> findSingleArgConstructor(Class<?>... argTypes)
576577
{
577578
for (AnnotatedConstructor ac : _classInfo.getConstructors()) {
578579
// This list is already filtered to only include accessible
579-
/* (note: for now this is a redundant check; but in future
580-
* that may change; thus leaving here for now)
581-
*/
582580
if (ac.getParameterCount() == 1) {
583581
Class<?> actArg = ac.getRawParameterType(0);
584582
for (Class<?> expArg : argTypes) {
@@ -592,6 +590,7 @@ public Constructor<?> findSingleArgConstructor(Class<?>... argTypes)
592590
}
593591

594592
@Override
593+
@Deprecated // since 2.13
595594
public Method findFactoryMethod(Class<?>... expArgTypes)
596595
{
597596
// So, of all single-arg static methods:
@@ -621,7 +620,8 @@ protected boolean isFactoryMethod(AnnotatedMethod am)
621620
}
622621
/* Also: must be a recognized factory method, meaning:
623622
* (a) marked with @JsonCreator annotation, or
624-
* (b) "valueOf" (at this point, need not be public)
623+
* (b) 1-argument "valueOf" (at this point, need not be public), or
624+
* (c) 1-argument "fromString()" AND takes {@code String} as the argument
625625
*/
626626
JsonCreator.Mode mode = _annotationIntrospector.findCreatorAnnotation(_config, am);
627627
if ((mode != null) && (mode != JsonCreator.Mode.DISABLED)) {

0 commit comments

Comments
 (0)