Skip to content

Commit 28ae21b

Browse files
committed
Adding Feature Flag for configurability.
1 parent 64ce4cf commit 28ae21b

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/JSON.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ public enum Feature
260260
* @since 2.5
261261
*/
262262
USE_IS_GETTERS(true, true),
263+
USE_FIELD_NAME_GETTERS(true,true),
263264

264265
/**
265266
* Feature that enables use of public fields instead of setters and getters,

jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/BeanPropertyIntrospector.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import com.fasterxml.jackson.jr.ob.impl.POJODefinition.Prop;
1313
import com.fasterxml.jackson.jr.ob.impl.POJODefinition.PropBuilder;
1414

15+
import static com.fasterxml.jackson.jr.ob.JSON.Feature.USE_FIELD_NAME_GETTERS;
16+
1517
/**
1618
* Helper class that jackson-jr uses by default to introspect POJO properties
1719
* (represented as {@link POJODefinition}) to build general POJO readers
@@ -139,7 +141,7 @@ private static void _introspect(Class<?> currType, Map<String, PropBuilder> prop
139141
name = decap(name.substring(2));
140142
_propFrom(props, name).withIsGetter(m);
141143
}
142-
} else {
144+
} else if(USE_FIELD_NAME_GETTERS.enabledByDefault()){
143145
// This will allow getters with field name as their getters, like the ones generated by Groovy
144146
boolean isDirectNameGetter = Arrays.stream(currType.getDeclaredFields()).map(Field::getName).anyMatch(f -> f.equals(m.getName()));
145147
if (isDirectNameGetter) {

jr-objects/src/test/groovy/com/fasterxml/jackson/jr/passing/GroovyTest.groovy renamed to jr-objects/src/test/groovy/com/fasterxml/jackson/jr/GroovyTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.jr.passing
1+
package com.fasterxml.jackson.jr
22

33
import com.fasterxml.jackson.jr.ob.JSON
44
import org.junit.Assert

0 commit comments

Comments
 (0)