@@ -45,8 +45,6 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri
45
45
46
46
private final Object value ;
47
47
48
- private Object source ;
49
-
50
48
private boolean optional = false ;
51
49
52
50
private boolean converted = false ;
@@ -78,12 +76,12 @@ public PropertyValue(PropertyValue original) {
78
76
Assert .notNull (original , "Original must not be null" );
79
77
this .name = original .getName ();
80
78
this .value = original .getValue ();
81
- this .source = original .getSource ();
82
79
this .optional = original .isOptional ();
83
80
this .converted = original .converted ;
84
81
this .convertedValue = original .convertedValue ;
85
82
this .conversionNecessary = original .conversionNecessary ;
86
83
this .resolvedTokens = original .resolvedTokens ;
84
+ setSource (original .getSource ());
87
85
copyAttributesFrom (original );
88
86
}
89
87
@@ -97,10 +95,10 @@ public PropertyValue(PropertyValue original, Object newValue) {
97
95
Assert .notNull (original , "Original must not be null" );
98
96
this .name = original .getName ();
99
97
this .value = newValue ;
100
- this .source = original ;
101
98
this .optional = original .isOptional ();
102
99
this .conversionNecessary = original .conversionNecessary ;
103
100
this .resolvedTokens = original .resolvedTokens ;
101
+ setSource (original );
104
102
copyAttributesFrom (original );
105
103
}
106
104
@@ -129,16 +127,28 @@ public Object getValue() {
129
127
*/
130
128
public PropertyValue getOriginalPropertyValue () {
131
129
PropertyValue original = this ;
132
- while (original .source instanceof PropertyValue && original .source != original ) {
133
- original = (PropertyValue ) original .source ;
130
+ Object source = getSource ();
131
+ while (source instanceof PropertyValue && source != original ) {
132
+ original = (PropertyValue ) source ;
133
+ source = original .getSource ();
134
134
}
135
135
return original ;
136
136
}
137
137
138
+ /**
139
+ * Set whether this is an optional value, that is, to be ignored
140
+ * when no corresponding property exists on the target class.
141
+ * @since 3.0
142
+ */
138
143
public void setOptional (boolean optional ) {
139
144
this .optional = optional ;
140
145
}
141
146
147
+ /**
148
+ * Reeurn whether this is an optional value, that is, to be ignored
149
+ * when no corresponding property exists on the target class.
150
+ * @since 3.0
151
+ */
142
152
public boolean isOptional () {
143
153
return this .optional ;
144
154
}
@@ -180,7 +190,7 @@ public boolean equals(Object other) {
180
190
PropertyValue otherPv = (PropertyValue ) other ;
181
191
return (this .name .equals (otherPv .name ) &&
182
192
ObjectUtils .nullSafeEquals (this .value , otherPv .value ) &&
183
- ObjectUtils .nullSafeEquals (this . source , otherPv .source ));
193
+ ObjectUtils .nullSafeEquals (getSource () , otherPv .getSource () ));
184
194
}
185
195
186
196
@ Override
0 commit comments