public synchronized void add(int index, FragmentProperty element) { // implement for modifiable AbstractList: FragmentPropertyImpl add = (FragmentPropertyImpl)element; if ((add.getName() == null) || (add.getValue() == null)) { throw new IllegalArgumentException("Property name and value must be set."); } // find existing matching property FragmentProperty addMatch = getMatchingProperty(add); if (addMatch != null) { // modify existing property addMatch.setValue(add.getValue()); } else { // try to recycle removed properties add = recycleProperty(add); // add new property properties.add(index, add); } }
public synchronized FragmentProperty set(int index, FragmentProperty element) { // implement for modifiable AbstractList: FragmentPropertyImpl set = (FragmentPropertyImpl)element; if ((set.getName() == null) || (set.getValue() == null)) { throw new IllegalArgumentException("Property name and value must be set."); } // find existing matching property FragmentProperty setMatch = getMatchingProperty(set); if (setMatch != null) { // modify existing property setMatch.setValue(set.getValue()); // remove property if not matching if (properties.get(index) != setMatch) { return remove(index); } return null; } else { // try to recycle removed properties set = recycleProperty(set); // replace property FragmentPropertyImpl replaced = (FragmentPropertyImpl)properties.set(index, set); return removedProperty(replaced); } }
if (targetProperty != null) targetProperty.setValue(sourceProperty.getValue());