@@ -29,6 +29,7 @@ public class DefaultASTDatabindingHelper implements ASTDatabindingHelper {
2929 public static final String BINDABLE_CONSTRAINT_NAME = "bindable" ;
3030
3131 public static final String DEFAULT_DATABINDING_WHITELIST = "$defaultDatabindingWhiteList" ;
32+ public static final String NO_BINDABLE_PROPERTIES = "$_NO_BINDABLE_PROPERTIES_$" ;
3233
3334 private static Map <ClassNode , Set <String >> CLASS_NODE_TO_WHITE_LIST_PROPERTY_NAMES = new HashMap <ClassNode , Set <String >>();
3435
@@ -95,31 +96,36 @@ protected AnnotationNode getMarkerAnnotation() {
9596
9697 private void addDefaultDatabindingWhitelistField (final SourceUnit sourceUnit , final ClassNode classNode ) {
9798 final FieldNode defaultWhitelistField = classNode .getDeclaredField (DEFAULT_DATABINDING_WHITELIST );
98- if (defaultWhitelistField == null ) {
99- final Set <String > propertyNamesToIncludeInWhiteList = getPropertyNamesToIncludeInWhiteList (sourceUnit , classNode );
100-
101- final ListExpression listExpression = new ListExpression ();
102- for (String propertyName : propertyNamesToIncludeInWhiteList ) {
99+ if (defaultWhitelistField != null ) {
100+ return ;
101+ }
102+
103+ final Set <String > propertyNamesToIncludeInWhiteList = getPropertyNamesToIncludeInWhiteList (sourceUnit , classNode );
104+
105+ final ListExpression listExpression = new ListExpression ();
106+ if (propertyNamesToIncludeInWhiteList .size () > 0 ) {
107+ for (String propertyName : propertyNamesToIncludeInWhiteList ) {
103108 listExpression .addExpression (new ConstantExpression (propertyName ));
104109
105110 final FieldNode declaredField = getDeclaredFieldInInheritanceHierarchy (classNode , propertyName );
106111 boolean isSimpleType = false ;
107- if (declaredField != null ) {
112+ if (declaredField != null ) {
108113 final ClassNode type = declaredField .getType ();
109- if (type != null ) {
114+ if (type != null ) {
110115 isSimpleType = SIMPLE_TYPES .contains (type );
111116 }
112117 }
113- if (!isSimpleType ) {
118+ if (!isSimpleType ) {
114119 listExpression .addExpression (new ConstantExpression (propertyName + "_*" ));
115120 listExpression .addExpression (new ConstantExpression (propertyName + ".*" ));
116121 }
117122 }
118-
119- classNode .addField (DEFAULT_DATABINDING_WHITELIST ,
120- Modifier .STATIC | Modifier .PUBLIC | Modifier .FINAL , new ClassNode (List .class ),
121- listExpression );
122- }
123+ } else {
124+ listExpression .addExpression (new ConstantExpression (NO_BINDABLE_PROPERTIES ));
125+ }
126+ classNode .addField (DEFAULT_DATABINDING_WHITELIST ,
127+ Modifier .STATIC | Modifier .PUBLIC | Modifier .FINAL , new ClassNode (List .class ),
128+ listExpression );
123129 }
124130
125131
0 commit comments