/** * Puts all of the writable properties from the given BeanMap into this * BeanMap. Read-only and Write-only properties will be ignored. * * @param map the BeanMap whose properties to put */ public void putAllWriteable(BeanMap map) { Iterator<String> readableKeys = map.readMethods.keySet().iterator(); while (readableKeys.hasNext()) { String key = readableKeys.next(); if (getWriteMethod(key) != null) { this.put(key, map.get(key)); } } }
/** * Sets the bean property with the given name to the given value. * * @param name the name of the property to set * @param value the value to set that property to * @return the previous value of that property */ @Override public Object put(String name, Object value) { if (bean != null) { Object oldValue = get(name); Method method = getWriteMethod(name); if (method == null) { throw new IllegalArgumentException("The bean of type: " + bean.getClass().getName() + " has no property called: " + name); } try { Object[] arguments = createWriteMethodArguments(method, value); method.invoke(bean, arguments); Object newValue = get(name); firePropertyChange(name, oldValue, newValue); } catch (InvocationTargetException e) { throw new IllegalArgumentException(e.getMessage()); } catch (IllegalAccessException e) { throw new IllegalArgumentException(e.getMessage()); } return oldValue; } return null; }
while (readableKeys.hasNext()) { String key = readableKeys.next(); if (getWriteMethod(key) != null) { newMap.put(key, get(key));
/** * Puts all of the writable properties from the given BeanMap into this * BeanMap. Read-only and Write-only properties will be ignored. * * @param map the BeanMap whose properties to put */ public void putAllWriteable(BeanMap map) { Iterator<String> readableKeys = map.readMethods.keySet().iterator(); while (readableKeys.hasNext()) { String key = readableKeys.next(); if (getWriteMethod(key) != null) { this.put(key, map.get(key)); } } }
/** * Sets the bean property with the given name to the given value. * * @param name the name of the property to set * @param value the value to set that property to * @return the previous value of that property */ @Override public Object put(String name, Object value) { if (bean != null) { Object oldValue = get(name); Method method = getWriteMethod(name); if (method == null) { throw new IllegalArgumentException("The bean of type: " + bean.getClass().getName() + " has no property called: " + name); } try { Object[] arguments = createWriteMethodArguments(method, value); method.invoke(bean, arguments); Object newValue = get(name); firePropertyChange(name, oldValue, newValue); } catch (InvocationTargetException e) { throw new IllegalArgumentException(e.getMessage()); } catch (IllegalAccessException e) { throw new IllegalArgumentException(e.getMessage()); } return oldValue; } return null; }
while (readableKeys.hasNext()) { String key = readableKeys.next(); if (getWriteMethod(key) != null) { newMap.put(key, get(key));