Mercurial > projects > dwt2
view org.eclipse.core.databinding.observable/src/org/eclipse/core/internal/databinding/observable/ConstantObservableValue.d @ 96:b74ac5dfcc06
package to module and java.lang.all import
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 21 Apr 2009 11:03:33 +0200 |
parents | 6208d4f6a277 |
children |
line wrap: on
line source
/******************************************************************************* * Copyright (c) 2005, 2007-2008 Matt Carter and others. * 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: * Matt Carter - initial API and implementation (bug 212518) * Matthew Hall - bug 212518 *******************************************************************************/ module org.eclipse.core.internal.databinding.observable.ConstantObservableValue; import java.lang.all; import org.eclipse.core.databinding.observable.IChangeListener; import org.eclipse.core.databinding.observable.IStaleListener; import org.eclipse.core.databinding.observable.ObservableTracker; import org.eclipse.core.databinding.observable.Realm; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.core.databinding.observable.value.IValueChangeListener; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.core.runtime.Assert; /** * An immutable {@link IObservableValue}. * * @see WritableValue */ public class ConstantObservableValue : IObservableValue { final Realm realm; final Object value; final Object type; /** * Construct a constant value of the given type, in the default realm. * * @param value * immutable value * @param type * type */ public this(Object value, Object type) { this(Realm.getDefault(), value, type); } /** * Construct a constant value of the given type, in the given realm. * * @param realm * Realm * @param value * immutable value * @param type * type */ public this(Realm realm, Object value, Object type) { Assert.isNotNull(realm, "Realm cannot be null"); //$NON-NLS-1$ this.realm = realm; this.value = value; this.type = type; } public Object getValueType() { return type; } public Object getValue() { ObservableTracker.getterCalled(this); return value; } public void setValue(Object value) { throw new UnsupportedOperationException(); } public void addValueChangeListener(IValueChangeListener listener) { // ignore } public void removeValueChangeListener(IValueChangeListener listener) { // ignore } public void addChangeListener(IChangeListener listener) { // ignore } public void addStaleListener(IStaleListener listener) { // ignore } public void dispose() { // nothing to dispose } public Realm getRealm() { return realm; } public bool isStale() { return false; } public void removeChangeListener(IChangeListener listener) { // ignore } public void removeStaleListener(IStaleListener listener) { // ignore } }