/** * Update given Object attribute by reading it from provided map properties. * * @param properties * which key-value pair of properties to assign those values to given object * @param obj * object which needs to be updated * @throws IllegalArgumentException * if the properties key-value contains incorrect value type */ public static <T> void update(Map<String, String> properties, T obj) throws IllegalArgumentException { Field[] fields = obj.getClass().getDeclaredFields(); Arrays.stream(fields).forEach(f -> { if (properties.containsKey(f.getName())) { try { f.setAccessible(true); f.set(obj, value((String) properties.get(f.getName()), f)); } catch (Exception e) { throw new IllegalArgumentException(format("failed to initialize %s field while setting value %s", f.getName(), properties.get(f.getName())), e); } } }); }
if (field != null && field.isAnnotationPresent(FieldContext.class)) { field.setAccessible(true); field.set(pulsar().getConfiguration(), FieldParser.value(value, field)); log.info("Successfully updated {}/{}", key, value); data.forEach((configKey, value) -> { Field configField = dynamicConfigurationMap.get(configKey); Object newValue = FieldParser.value(data.get(configKey), configField); if (configField != null) { Consumer listener = configRegisteredListeners.get(configKey);