package de.fosd.jdime.gui;

import java.util.Objects;

/**
 * A Bean encapsulating the state of the gui at one point.
 */
final class State {

	private String output;
	private String left;
	private String base;
	private String right;
	private String jDime;
	private String cmdArgs;

	private State() {}

	public static State of(GUI gui) {
		State state = new State();

		state.output = gui.output.getText();
		state.left = gui.left.getText();
		state.base = gui.base.getText();
		state.right = gui.right.getText();
		state.jDime = gui.jDime.getText();
		state.cmdArgs = gui.cmdArgs.getText();

		return state;
	}

	public void applyTo(GUI gui) {
		gui.output.setText(output);
		gui.left.setText(left);
		gui.base.setText(base);
		gui.right.setText(right);
		gui.jDime.setText(jDime);
		gui.cmdArgs.setText(cmdArgs);
	}

	public String getOutput() {
		return output;
	}

	public String getLeft() {
		return left;
	}

	public String getBase() {
		return base;
	}

	public String getRight() {
		return right;
	}

	public String getjDime() {
		return jDime;
	}

	public String getCmdArgs() {
		return cmdArgs;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}

		if (o == null || getClass() != o.getClass()) {
			return false;
		}

		State state = (State) o;

		return Objects.equals(output, state.output) &&
				Objects.equals(left, state.left) &&
				Objects.equals(base, state.base) &&
				Objects.equals(right, state.right) &&
				Objects.equals(jDime, state.jDime) &&
				Objects.equals(cmdArgs, state.cmdArgs);
	}

	@Override
	public int hashCode() {
		return Objects.hash(output, left, base, right, jDime, cmdArgs);
	}
}

@@ -294,18 +294,256 @@
 tate() %7B
-%7D
 %0A
+%0A%09%7D%0A%0A%09/**%0A%09 * Returns a %3Ccode%3EState%3C/code%3E instance containing the current state of the given %3Ccode%3EGUI%3C/code%3E.%0A%09 *%0A%09 * @param gui%0A%09 * %09%09the %3Ccode%3EGUI%3C/code%3E whose state is to be copied%0A%09 *%0A%09 * @return the resulting %3Ccode%3EState%3C/code%3E%0A%09 */
 %0A%09public
@@ -841,24 +841,249 @@
  state;%0A%09%7D%0A%0A
+%09/**%0A%09 * Applies the state stored in this %3Ccode%3EState%3C/code%3E to the given %3Ccode%3EGUI%3C/code%3E. Must be called in the%0A%09 * JavaFX Application thread.%0A%09 *%0A%09 * @param gui%0A%09 * %09%09the %3Ccode%3EGUI%3C/code%3E to apply the stored state to%0A%09 */%0A
 %09public void

reformat and doc