Skip to content

Commit a26c015

Browse files
authored
Implement new BeanPropertyDefinition.getAliases() method (#4336)
1 parent 52ca177 commit a26c015

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

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

+13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fasterxml.jackson.databind.introspect;
22

3+
import java.util.Collections;
34
import java.util.Iterator;
5+
import java.util.List;
46

57
import com.fasterxml.jackson.annotation.JsonInclude;
68

@@ -284,4 +286,15 @@ public String findReferenceName() {
284286
* @since 2.5
285287
*/
286288
public abstract JsonInclude.Value findInclusion();
289+
290+
/**
291+
* Method for finding all aliases of the property, if any.
292+
*
293+
* @return {@code List} of aliases, if any; never null (empty list if no aliases found)
294+
*
295+
* @since 2.17
296+
*/
297+
public List<PropertyName> findAliases() {
298+
return Collections.emptyList();
299+
}
287300
}

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

+13
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,19 @@ public JsonInclude.Value findInclusion() {
843843
return (v == null) ? JsonInclude.Value.empty() : v;
844844
}
845845

846+
// since 2.17
847+
@Override
848+
public List<PropertyName> findAliases() {
849+
AnnotatedMember ann = getPrimaryMember();
850+
if (ann != null) {
851+
List<PropertyName> propertyNames = _annotationIntrospector.findPropertyAliases(ann);
852+
if (propertyNames != null) {
853+
return propertyNames;
854+
}
855+
}
856+
return Collections.emptyList();
857+
}
858+
846859
public JsonProperty.Access findAccess() {
847860
return fromMemberAnnotationsExcept(new WithMember<JsonProperty.Access>() {
848861
@Override

src/main/java/com/fasterxml/jackson/databind/util/SimpleBeanPropertyDefinition.java

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.Collections;
44
import java.util.Iterator;
5+
import java.util.List;
56

67
import com.fasterxml.jackson.annotation.JsonInclude;
78

@@ -218,6 +219,18 @@ public JsonInclude.Value findInclusion() {
218219
return _inclusion;
219220
}
220221

222+
@Override // since 2.17
223+
public List<PropertyName> findAliases() {
224+
AnnotatedMember ann = getPrimaryMember();
225+
if (ann != null) {
226+
List<PropertyName> propertyNames = _annotationIntrospector.findPropertyAliases(ann);
227+
if (propertyNames != null) {
228+
return propertyNames;
229+
}
230+
}
231+
return Collections.emptyList();
232+
}
233+
221234
/*
222235
/**********************************************************
223236
/* Access to accessors (fields, methods etc)

0 commit comments

Comments
 (0)