BeanUtils.setProperty(top, actualName, actualValue);
BeanUtils.setProperty(top, propName, value);
BeanUtils.setProperty(top, property, bodyText);
BeanUtils.setProperty( obj, property, val ); } catch ( Exception e ) { throw new KettleConfigException( e );
protected OpenConextOAuthClient createOpenConextOAuthClient(Properties properties) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException { OpenConextOAuthClient apiClient = (OpenConextOAuthClient) getClass().getClassLoader().loadClass(properties.getProperty("openConextApiClient")).newInstance(); BeanUtils.setProperty(apiClient, "callbackUrl", properties.getProperty("api-callbackuri")); BeanUtils.setProperty(apiClient, "consumerSecret", properties.getProperty("api-consumersecret")); BeanUtils.setProperty(apiClient, "consumerKey", properties.getProperty("api-consumerkey")); BeanUtils.setProperty(apiClient, "endpointBaseUrl", properties.getProperty("api-baseurl")); return apiClient; }
public static void setObjectProperty(Object object,String property,Object value){ try { BeanUtils.setProperty(object, property, value); } catch (Exception e) { throw new RuleException(e); } }
protected void initializeFromProperties(MuleConfiguration configuration) { for (Map.Entry<String, String> entry : artifactProperties.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (key.startsWith(SYS_PROPERTY_PREFIX)) { String systemProperty = key.substring(SYS_PROPERTY_PREFIX.length()); System.setProperty(systemProperty, value); } else if (key.startsWith(MULE_PROPERTY_PREFIX)) { String configProperty = key.substring(MULE_PROPERTY_PREFIX.length()); try { setProperty(configuration, configProperty, value); } catch (IllegalAccessException | InvocationTargetException e) { logger.error("Cannot set configuration property", e); } } } } }
private static CacheConfiguration createCacheConfiguration(OpenmrsCacheConfiguration openmrsCacheConfiguration) { CacheConfiguration cacheConfiguration = new CacheConfiguration(); openmrsCacheConfiguration.getAllKeys() .forEach(key -> { try { BeanUtils.setProperty(cacheConfiguration, key, openmrsCacheConfiguration.getProperty(key)); } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException(e); } }); return cacheConfiguration; }
private void updateImmutableFieldsAndAssert(Obs obs, boolean assertion) throws Exception { //Set all fields to some random values via reflection List<Field> fields = Reflect.getAllFields(Obs.class); final Integer originalPersonId = obs.getPersonId(); //call each setter and check that dirty has been set to true for each for (Field field : fields) { String fieldName = field.getName(); if (IGNORED_FIELDS.contains(fieldName)) { continue; } if ("personId".equals(fieldName)) { //call setPersonId because it is protected so BeanUtils.setProperty won't work obs.setPersonId((Integer) generateValue(field, true)); } else { BeanUtils.setProperty(obs, fieldName, generateValue(field, true)); } assertEquals("Obs was not marked as dirty after changing: " + fieldName, obs.isDirty(), assertion); if ("person".equals(fieldName)) { //Because setPerson updates the personId we need to reset personId to its original value //that matches that of person otherwise the test will fail for the personId field obs.setPersonId(originalPersonId); } //reset for next field resetObs(obs); } }
protected void setData(Object instance, Map<String, Object> data) throws IOException { try { BeanUtils.setProperty(instance, DATA, data); } catch (IllegalAccessException e) { throw new IllegalStateException("Failed to set data [" + data + "] on [" + instance + "]", e); } catch (InvocationTargetException e) { throw new IllegalStateException("Failed to set data [" + data + "] on [" + instance + "]", e); } }
protected void set(Object obj, String property, Object value) { try { if (BeanUtils.getProperty(obj, property) == null) { BeanUtils.setProperty(obj, property, value); } } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { } catch (NoSuchMethodException e) { } }
protected void set(Object obj, String property, Object value) { try { if (BeanUtils.getProperty(obj, property) == null) { BeanUtils.setProperty(obj, property, value); } } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { } catch (NoSuchMethodException e) { } }
public void setField(String fieldName, final String value) { try { fieldName = processFieldName(fieldName); BeanUtils.setProperty(this, fieldName, value); } catch (final Exception e) { log.warn("Unable to set field using reflection for :" + fieldName + ":" + value); } }
public void overrideConfig(Map<String, Object> tuningConfig) { if(MapUtils.isNotEmpty(tuningConfig)) { for (String key : tuningConfig.keySet()) { try { BeanUtils.setProperty(this, key, tuningConfig.get(key)); } catch (Exception e) { } } } }
public void overrideConfig(Map<String, Object> tuningConfig) { this.buildV9Directly = true; if(MapUtils.isNotEmpty(tuningConfig)) { for (String key : tuningConfig.keySet()) { try { BeanUtils.setProperty(this, key, tuningConfig.get(key)); } catch (Exception e) { } } } }
private static <P> void setAnnotatedField(P pojo, Map<String, Object> props, String name, Object value) { if (value != null && !props.containsKey(name)) { try { // perform micro conversion to the correct field type BeanUtils.setProperty(pojo, name, value); } catch (Exception e) { if (!isPropertiesField(name)) { props.put(name, value); } } } }
/** * @see org.opencms.configuration.preferences.I_CmsPreference#setValue(org.opencms.configuration.CmsDefaultUserSettings, java.lang.String) */ public void setValue(CmsDefaultUserSettings settings, String value) { CmsUserSettingsStringPropertyWrapper wrapper = new CmsUserSettingsStringPropertyWrapper(settings); try { BeanUtils.setProperty(wrapper, m_propName, value); } catch (Exception e) { LOG.error(e.getLocalizedMessage(), e); } }
public Rule setArgs(Rule rule) { this.arguments.forEach(arguments -> { try { BeanUtils.setProperty(rule, arguments.getName(), arguments.getValue()); } catch (IllegalAccessException | InvocationTargetException e) { new RuntimeException("error!" + e.getMessage()); } }); return rule; }
public void patchEntity(Object obj, String... props) { for(String prop : props) { if(!hasProperty(prop)) { continue; } try { BeanUtils.setProperty(obj, prop, getValue(prop)); } catch (IllegalAccessException | InvocationTargetException e) { LOGGER.warn("Fail to patch property({}) from bean({})", prop, obj.getClass().getName()); } } }
protected Object build(String key) throws Exception { Object bean = newInstance(map.get(key)); Map<String, String> attributes = attributesByBeanRef(key); if (!attributes.isEmpty()) { for (Entry<String, String> e : attributes.entrySet()) { final String v = e.getValue(); BeanUtils.setProperty(bean, e.getKey(), v.startsWith(BEAN_ID_PREFIX) ? get(v) : v); } } return bean; }