Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 222262539f599f24d7f77a8701dda5b4708c081f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*******************************************************************************
 *  Copyright (c) 2009  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.utility.internal.model.value;

import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;

/**
 * A simple implementation of {@link WritablePropertyValueModel} that actually
 * ... <i>isn't</i> ... writable.  It can however be used in places that require a 
 * {@link WritablePropertyValueModel} and where the developer is sure that no 
 * attempt will be made to write to it.
 */
public class ReadOnlyWritablePropertyValueModelWrapper<T>
	extends PropertyValueModelWrapper<T>
	implements WritablePropertyValueModel<T>
{
	public ReadOnlyWritablePropertyValueModelWrapper(PropertyValueModel<? extends T> valueHolder) {
		super(valueHolder);
	}
	
	
	public T getValue() {
		return this.valueHolder.getValue();
	}
	
	public void setValue(T value) {
		throw new UnsupportedOperationException("setValue");
	}
	
	@Override
	protected void valueChanged(PropertyChangeEvent event) {
		firePropertyChanged(event.cloneWithSource(this));
	}
}

Back to the top