Changeset 10223 in josm for trunk/src/org/openstreetmap/josm/data/Preferences.java
- Timestamp:
- 2016-05-16T04:05:58+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r10212 r10223 1203 1203 structPrototype = klass.getConstructor().newInstance(); 1204 1204 } catch (ReflectiveOperationException ex) { 1205 throw new RuntimeException(ex);1205 throw new IllegalArgumentException(ex); 1206 1206 } 1207 1207 … … 1211 1211 continue; 1212 1212 } 1213 f.setAccessible(true);1213 Utils.setObjectsAccessible(f); 1214 1214 try { 1215 1215 Object fieldValue = f.get(struct); 1216 1216 Object defaultFieldValue = f.get(structPrototype); 1217 if (fieldValue != null) { 1218 if (f.getAnnotation(writeExplicitly.class) != null || !Objects.equals(fieldValue, defaultFieldValue)) { 1219 String key = f.getName().replace('_', '-'); 1220 if (fieldValue instanceof Map) { 1221 hash.put(key, mapToJson((Map) fieldValue)); 1222 } else if (fieldValue instanceof MultiMap) { 1223 hash.put(key, multiMapToJson((MultiMap) fieldValue)); 1224 } else { 1225 hash.put(key, fieldValue.toString()); 1226 } 1217 if (fieldValue != null && (f.getAnnotation(writeExplicitly.class) != null || !Objects.equals(fieldValue, defaultFieldValue))) { 1218 String key = f.getName().replace('_', '-'); 1219 if (fieldValue instanceof Map) { 1220 hash.put(key, mapToJson((Map<?, ?>) fieldValue)); 1221 } else if (fieldValue instanceof MultiMap) { 1222 hash.put(key, multiMapToJson((MultiMap<?, ?>) fieldValue)); 1223 } else { 1224 hash.put(key, fieldValue.toString()); 1227 1225 } 1228 1226 } 1229 } catch (IllegalA rgumentException | IllegalAccessException ex) {1227 } catch (IllegalAccessException ex) { 1230 1228 throw new RuntimeException(ex); 1231 1229 } … … 1261 1259 } catch (NoSuchFieldException ex) { 1262 1260 continue; 1263 } catch (SecurityException ex) {1264 throw new RuntimeException(ex);1265 1261 } 1266 1262 if (f.getAnnotation(pref.class) == null) { 1267 1263 continue; 1268 1264 } 1269 f.setAccessible(true);1265 Utils.setObjectsAccessible(f); 1270 1266 if (f.getType() == Boolean.class || f.getType() == boolean.class) { 1271 1267 value = Boolean.valueOf(key_value.getValue()); … … 1326 1322 try { 1327 1323 Field field = Toolkit.class.getDeclaredField("resources"); 1328 field.setAccessible(true);1324 Utils.setObjectsAccessible(field); 1329 1325 field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt")); 1330 1326 } catch (ReflectiveOperationException e) {
Note:
See TracChangeset
for help on using the changeset viewer.