diff options
Diffstat (limited to 'common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyCollectionValueModelAdapter.java')
-rw-r--r-- | common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyCollectionValueModelAdapter.java | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyCollectionValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyCollectionValueModelAdapter.java deleted file mode 100644 index 694a681933..0000000000 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyCollectionValueModelAdapter.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2012 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.common.utility.internal.model.value; - -import java.util.Iterator; - -import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel; -import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel; - -/** - * An adapter that allows us to make a {@link ModifiablePropertyValueModel} behave like - * a single-element {@link ModifiableCollectionValueModel}, sorta. - * <p> - * If the property's value is <code>null</code>, an empty iterator is returned - * (i.e. you can't have a collection with a <code>null</code> element). - * Also, only a single-element collection can be written to the adapter. - */ -public class ModifiablePropertyCollectionValueModelAdapter<E> - extends PropertyCollectionValueModelAdapter<E> - implements ModifiableCollectionValueModel<E> -{ - // ********** constructor ********** - - /** - * Convert the specified writable property value model to a writable - * collection value model. - */ - public ModifiablePropertyCollectionValueModelAdapter(ModifiablePropertyValueModel<E> valueHolder) { - super(valueHolder); - } - - - // ********** WritableCollectionValueModel implementation ********** - - public void setValues(Iterable<E> values) { - Iterator<E> stream = values.iterator(); - if (stream.hasNext()) { - E newValue = stream.next(); - if (stream.hasNext()) { - throw new IllegalArgumentException("non-singleton collection: " + values); //$NON-NLS-1$ - } - this.getValueHolder().setValue(newValue); - } else { - this.getValueHolder().setValue(null); - } - } - - // our constructor takes only writable property value models - @SuppressWarnings("unchecked") - protected ModifiablePropertyValueModel<E> getValueHolder() { - return (ModifiablePropertyValueModel<E>) this.valueHolder; - } -} |