/** * 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)); } } }
@Override public long execute() { int rv = 0; for (T match : query.fetch()) { BeanMap beanMap = new BeanMap(match); for (Map.Entry<Path<?>,Object> entry : paths.entrySet()) { // TODO : support deep updates as well String propertyName = entry.getKey().getMetadata().getName(); beanMap.put(propertyName, entry.getValue()); } rv++; } return rv; }
/** * Sets the value. * * @param value the new value for the entry * @return the old value for the entry */ @Override public Object setValue(Object value) { String key = getKey(); Object oldValue = owner.get(key); owner.put(key, value); Object newValue = owner.get(key); this.value = newValue; return oldValue; }
String key = readableKeys.next(); if (getWriteMethod(key) != null) { newMap.put(key, get(key));
@Test public void entrySet() { beanMap.put("firstName", "John"); assertFalse(beanMap.entrySet().isEmpty()); }
@Test public void getString() { beanMap.put("firstName", "John"); assertEquals("John", beanMap.get("firstName")); }
@Test @Ignore public void values() { beanMap.put("firstName", "John"); assertEquals(Lists.newArrayList(0, null, Entity.class, "John"), beanMap.values()); }
@Test public void primitives() { beanMap.put("id", 5); assertEquals(5, ((Entity) beanMap.getBean()).getId()); }
/** * 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)); } } }
@Override public long execute() { int rv = 0; for (T match : query.fetch()) { BeanMap beanMap = new BeanMap(match); for (Map.Entry<Path<?>,Object> entry : paths.entrySet()) { // TODO : support deep updates as well String propertyName = entry.getKey().getMetadata().getName(); beanMap.put(propertyName, entry.getValue()); } rv++; } return rv; }
String key = readableKeys.next(); if (getWriteMethod(key) != null) { newMap.put(key, get(key));
/** * Sets the value. * * @param value the new value for the entry * @return the old value for the entry */ @Override public Object setValue(Object value) { String key = getKey(); Object oldValue = owner.get(key); owner.put(key, value); Object newValue = owner.get(key); this.value = newValue; return oldValue; }