16
16
import java .util .List ;
17
17
import java .util .stream .Collectors ;
18
18
19
+ import static org .jgroups .conf .AttributeType .TIME ;
20
+
19
21
/**
20
22
* Groups a set of standard PropertyConverter(s) supplied by JGroups.
21
23
*
@@ -164,34 +166,33 @@ public Object convert(Object obj, Class<?> propertyFieldType, String propertyNam
164
166
}
165
167
166
168
@ Override
167
- public Object convert (Property annotation , Object obj , Class <?> propertyFieldType , String propertyName , String propertyValue ,
169
+ public Object convert (Property ann , Object obj , Class <?> propertyFieldType , String propertyName , String propValue ,
168
170
boolean check_scope , StackType ip_version ) throws Exception {
169
- if (propertyValue == null )
171
+ if (propValue == null )
170
172
throw new NullPointerException ("Property value cannot be null" );
171
173
172
174
if (Boolean .TYPE .equals (propertyFieldType ))
173
- return Boolean .parseBoolean (propertyValue );
175
+ return Boolean .parseBoolean (propValue );
174
176
if (Integer .TYPE .equals (propertyFieldType ))
175
- return Util .readBytesInteger (propertyValue );
176
- if (Long .TYPE .equals (propertyFieldType )) {
177
- return annotation != null && annotation .type () == AttributeType .TIME ? Util .readDurationLong (propertyValue , annotation .unit ()) : Util .readBytesLong (propertyValue );
178
- }
177
+ return ann != null && ann .type () == TIME ? Util .readDurationInt (propValue , ann .unit ()) : Util .readBytesInteger (propValue );
178
+ if (Long .TYPE .equals (propertyFieldType ))
179
+ return ann != null && ann .type () == TIME ? Util .readDurationLong (propValue , ann .unit ()) : Util .readBytesLong (propValue );
179
180
if (Byte .TYPE .equals (propertyFieldType ))
180
- return Byte .parseByte (propertyValue );
181
+ return Byte .parseByte (propValue );
181
182
if (Double .TYPE .equals (propertyFieldType ))
182
- return Util .readBytesDouble (propertyValue );
183
+ return Util .readBytesDouble (propValue );
183
184
if (Short .TYPE .equals (propertyFieldType ))
184
- return Short .parseShort (propertyValue );
185
+ return Short .parseShort (propValue );
185
186
if (Float .TYPE .equals (propertyFieldType ))
186
- return Float .parseFloat (propertyValue );
187
+ return Float .parseFloat (propValue );
187
188
if (String [].class .equals (propertyFieldType ))
188
- return Util .parseStringArray (propertyValue , "," );
189
+ return Util .parseStringArray (propValue , "," );
189
190
if (propertyFieldType .isEnum ())
190
- return Util .createEnum (propertyValue , propertyFieldType );
191
+ return Util .createEnum (propValue , propertyFieldType );
191
192
if (InetAddress .class .equals (propertyFieldType )) {
192
193
InetAddress retval =null ;
193
- if (propertyValue .contains ("," )) {
194
- List <String > addrs =Util .parseCommaDelimitedStrings (propertyValue );
194
+ if (propValue .contains ("," )) {
195
+ List <String > addrs =Util .parseCommaDelimitedStrings (propValue );
195
196
for (String addr : addrs ) {
196
197
try {
197
198
retval =Util .getAddress (addr , ip_version );
@@ -202,10 +203,10 @@ public Object convert(Property annotation, Object obj, Class<?> propertyFieldTyp
202
203
}
203
204
}
204
205
if (retval == null )
205
- throw new IllegalArgumentException (String .format ("failed parsing attribute %s with value %s" , propertyName , propertyValue ));
206
+ throw new IllegalArgumentException (String .format ("failed parsing attribute %s with value %s" , propertyName , propValue ));
206
207
}
207
208
else
208
- retval =Util .getAddress (propertyValue , ip_version );
209
+ retval =Util .getAddress (propValue , ip_version );
209
210
210
211
if (check_scope && retval instanceof Inet6Address && retval .isLinkLocalAddress ()) {
211
212
// check scope
@@ -220,7 +221,7 @@ public Object convert(Property annotation, Object obj, Class<?> propertyFieldTyp
220
221
}
221
222
return retval ;
222
223
}
223
- return propertyValue ;
224
+ return propValue ;
224
225
}
225
226
226
227
0 commit comments