1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -46,8 +46,6 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri
46
46
47
47
private final Object value ;
48
48
49
- private Object source ;
50
-
51
49
private boolean optional = false ;
52
50
53
51
private boolean converted = false ;
@@ -82,13 +80,13 @@ public PropertyValue(PropertyValue original) {
82
80
Assert .notNull (original , "Original must not be null" );
83
81
this .name = original .getName ();
84
82
this .value = original .getValue ();
85
- this .source = original .getSource ();
86
83
this .optional = original .isOptional ();
87
84
this .converted = original .converted ;
88
85
this .convertedValue = original .convertedValue ;
89
86
this .conversionNecessary = original .conversionNecessary ;
90
87
this .resolvedTokens = original .resolvedTokens ;
91
88
this .resolvedDescriptor = original .resolvedDescriptor ;
89
+ setSource (original .getSource ());
92
90
copyAttributesFrom (original );
93
91
}
94
92
@@ -102,11 +100,11 @@ public PropertyValue(PropertyValue original, Object newValue) {
102
100
Assert .notNull (original , "Original must not be null" );
103
101
this .name = original .getName ();
104
102
this .value = newValue ;
105
- this .source = original ;
106
103
this .optional = original .isOptional ();
107
104
this .conversionNecessary = original .conversionNecessary ;
108
105
this .resolvedTokens = original .resolvedTokens ;
109
106
this .resolvedDescriptor = original .resolvedDescriptor ;
107
+ setSource (original );
110
108
copyAttributesFrom (original );
111
109
}
112
110
@@ -135,16 +133,28 @@ public Object getValue() {
135
133
*/
136
134
public PropertyValue getOriginalPropertyValue () {
137
135
PropertyValue original = this ;
138
- while (original .source instanceof PropertyValue && original .source != original ) {
139
- original = (PropertyValue ) original .source ;
136
+ Object source = getSource ();
137
+ while (source instanceof PropertyValue && source != original ) {
138
+ original = (PropertyValue ) source ;
139
+ source = original .getSource ();
140
140
}
141
141
return original ;
142
142
}
143
143
144
+ /**
145
+ * Set whether this is an optional value, that is, to be ignored
146
+ * when no corresponding property exists on the target class.
147
+ * @since 3.0
148
+ */
144
149
public void setOptional (boolean optional ) {
145
150
this .optional = optional ;
146
151
}
147
152
153
+ /**
154
+ * Return whether this is an optional value, that is, to be ignored
155
+ * when no corresponding property exists on the target class.
156
+ * @since 3.0
157
+ */
148
158
public boolean isOptional () {
149
159
return this .optional ;
150
160
}
@@ -186,7 +196,7 @@ public boolean equals(Object other) {
186
196
PropertyValue otherPv = (PropertyValue ) other ;
187
197
return (this .name .equals (otherPv .name ) &&
188
198
ObjectUtils .nullSafeEquals (this .value , otherPv .value ) &&
189
- ObjectUtils .nullSafeEquals (this . source , otherPv .source ));
199
+ ObjectUtils .nullSafeEquals (getSource () , otherPv .getSource () ));
190
200
}
191
201
192
202
@ Override
0 commit comments