/*******************************************************************************
 * Copyright (c) 2012 Pivotal Software, Inc.
 * 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:
 *    Pivotal Software, Inc. - initial API and implementation
 *******************************************************************************/
package org.springsource.ide.eclipse.commons.livexp.core;

/**
 * A concrete implementation of LiveExpression that represents a single storage cell in
 * which a value of a given type can be stored.
 * <p>
 * Can be used in Mockup UIs for testing. Here a LiveVariable can take the place of
 * an input field in the GUI. Core functionality can then be tested against the
 * headless Mock in which it is easy to set values.
 *
 * @author Kris De Volder
 */
public class LiveVariable<T> extends LiveExpression<T> {

	private T storedValue;

	public LiveVariable(T initialValue, Object owner) {
		super(initialValue, owner);
	}

	public LiveVariable(T initialValue) {
		this(initialValue, null);
	}

	public LiveVariable() {
		this(null);
	}

	@Override
	protected T compute() {
		return storedValue;
	}

	public void setValue(T v) {
		storedValue = v;
		refresh();
	}

}

@@ -1395,10 +1395,93 @@
 ();%0A%09%7D%0A%0A
+%09@Override%0A%09public String toString() %7B%0A%09%09return %22LiveVariable(%22+getValue()+%22)%22;%0A%09%7D%0A
 %7D%0A

Add a toString to LiveVariable for easier debugging of code using them