Skip to content

Commit

Permalink
Adding Feature Flag for configurability.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shounaks committed Feb 27, 2024
1 parent 64ce4cf commit 28ae21b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public enum Feature
* @since 2.5
*/
USE_IS_GETTERS(true, true),
USE_FIELD_NAME_GETTERS(true,true),

/**
* Feature that enables use of public fields instead of setters and getters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import com.fasterxml.jackson.jr.ob.impl.POJODefinition.Prop;
import com.fasterxml.jackson.jr.ob.impl.POJODefinition.PropBuilder;

import static com.fasterxml.jackson.jr.ob.JSON.Feature.USE_FIELD_NAME_GETTERS;

/**
* Helper class that jackson-jr uses by default to introspect POJO properties
* (represented as {@link POJODefinition}) to build general POJO readers
Expand Down Expand Up @@ -139,7 +141,7 @@ private static void _introspect(Class<?> currType, Map<String, PropBuilder> prop
name = decap(name.substring(2));
_propFrom(props, name).withIsGetter(m);
}
} else {
} else if(USE_FIELD_NAME_GETTERS.enabledByDefault()){
// This will allow getters with field name as their getters, like the ones generated by Groovy
boolean isDirectNameGetter = Arrays.stream(currType.getDeclaredFields()).map(Field::getName).anyMatch(f -> f.equals(m.getName()));
if (isDirectNameGetter) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.jr.passing
package com.fasterxml.jackson.jr

import com.fasterxml.jackson.jr.ob.JSON
import org.junit.Assert
Expand Down

0 comments on commit 28ae21b

Please sign in to comment.