/** * Add a PropertyValue object, replacing any existing one for the * corresponding property or getting merged with it (if applicable). * @param pv the PropertyValue object to add * @return this in order to allow for adding multiple property values in a chain */ public MutablePropertyValues addPropertyValue(PropertyValue pv) { for (int i = 0; i < this.propertyValueList.size(); i++) { PropertyValue currentPv = this.propertyValueList.get(i); if (currentPv.getName().equals(pv.getName())) { pv = mergeIfRequired(pv, currentPv); setPropertyValueAt(pv, i); return this; } } this.propertyValueList.add(pv); return this; }
/** * Add a PropertyValue object, replacing any existing one for the * corresponding property or getting merged with it (if applicable). * @param pv the PropertyValue object to add * @return this in order to allow for adding multiple property values in a chain */ public MutablePropertyValues addPropertyValue(PropertyValue pv) { for (int i = 0; i < this.propertyValueList.size(); i++) { PropertyValue currentPv = this.propertyValueList.get(i); if (currentPv.getName().equals(pv.getName())) { pv = mergeIfRequired(pv, currentPv); setPropertyValueAt(pv, i); return this; } } this.propertyValueList.add(pv); return this; }
@Test public void testValid() { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.addPropertyValue(new PropertyValue("forname", "Tony")); pvs.addPropertyValue(new PropertyValue("surname", "Blair")); pvs.addPropertyValue(new PropertyValue("age", "50")); doTestTony(pvs); MutablePropertyValues deepCopy = new MutablePropertyValues(pvs); doTestTony(deepCopy); deepCopy.setPropertyValueAt(new PropertyValue("name", "Gordon"), 0); doTestTony(pvs); assertEquals("Gordon", deepCopy.getPropertyValue("name").getValue()); }
mpvs.setPropertyValueAt(new PropertyValue(refName, pv.getValue()), i); break;
/** * Add a PropertyValue object, replacing any existing one for the * corresponding property or getting merged with it (if applicable). * @param pv PropertyValue object to add * @return this in order to allow for adding multiple property values in a chain */ public MutablePropertyValues addPropertyValue(PropertyValue pv) { for (int i = 0; i < this.propertyValueList.size(); i++) { PropertyValue currentPv = this.propertyValueList.get(i); if (currentPv.getName().equals(pv.getName())) { pv = mergeIfRequired(pv, currentPv); setPropertyValueAt(pv, i); return this; } } this.propertyValueList.add(pv); return this; }
/** * Add a PropertyValue object, replacing any existing one * for the corresponding property. * @param pv PropertyValue object to add * @return this object to allow creating objects, adding multiple * PropertyValues in a single statement */ public MutablePropertyValues addPropertyValue(PropertyValue pv) { for (int i = 0; i < this.propertyValueList.size(); i++) { PropertyValue currentPv = (PropertyValue) this.propertyValueList.get(i); if (currentPv.getName().equals(pv.getName())) { setPropertyValueAt(pv, i); return this; } } this.propertyValueList.add(pv); return this; }
/** * Add a PropertyValue object, replacing any existing one for the * corresponding property or getting merged with it (if applicable). * @param pv PropertyValue object to add * @return this in order to allow for adding multiple property values in a chain */ public MutablePropertyValues addPropertyValue(PropertyValue pv) { for (int i = 0; i < this.propertyValueList.size(); i++) { PropertyValue currentPv = this.propertyValueList.get(i); if (currentPv.getName().equals(pv.getName())) { pv = mergeIfRequired(pv, currentPv); setPropertyValueAt(pv, i); return this; } } this.propertyValueList.add(pv); return this; }