tikhomirov@360: /*
tikhomirov@454:  * Copyright (c) 2011-2012 TMate Software Ltd
tikhomirov@360:  *  
tikhomirov@360:  * This program is free software; you can redistribute it and/or modify
tikhomirov@360:  * it under the terms of the GNU General Public License as published by
tikhomirov@360:  * the Free Software Foundation; version 2 of the License.
tikhomirov@360:  *
tikhomirov@360:  * This program is distributed in the hope that it will be useful,
tikhomirov@360:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
tikhomirov@360:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
tikhomirov@360:  * GNU General Public License for more details.
tikhomirov@360:  *
tikhomirov@360:  * For information on how to redistribute this software under
tikhomirov@360:  * the terms of a license other than GNU General Public License
tikhomirov@360:  * contact TMate Software at support@hg4j.com
tikhomirov@360:  */
tikhomirov@360: package org.tmatesoft.hg.util;
tikhomirov@360: 
tikhomirov@360: /**
tikhomirov@360:  * Success/failure descriptor. When exception is too much.
tikhomirov@360:  * 
tikhomirov@360:  * @author Artem Tikhomirov
tikhomirov@360:  * @author TMate Software Ltd.
tikhomirov@360:  */
tikhomirov@456: public final class Outcome {
tikhomirov@360: 	// XXX perhaps private enum and factory method createError() and createOk()?
tikhomirov@360: 	public enum Kind {
tikhomirov@454: 		Success, Failure;
tikhomirov@360: 	}
tikhomirov@360: 
tikhomirov@360: 	private final Kind kind;
tikhomirov@360: 	private final String message;
tikhomirov@360: 	private final Exception error;
tikhomirov@360: 
tikhomirov@454: 	public Outcome(Kind k, String msg) {
tikhomirov@360: 		this(k, msg, null);
tikhomirov@360: 	}
tikhomirov@360: 	
tikhomirov@454: 	public Outcome(Kind k, String msg, Exception err) {
tikhomirov@360: 		kind = k;
tikhomirov@360: 		message = msg;
tikhomirov@360: 		error = err;
tikhomirov@360: 	}
tikhomirov@360: 	
tikhomirov@360: 	public boolean isOk() {
tikhomirov@454: 		return kind == Kind.Success;
tikhomirov@360: 	}
tikhomirov@360: 	
tikhomirov@360: 	public Kind getKind() {
tikhomirov@360: 		return kind;
tikhomirov@360: 	}
tikhomirov@360: 
tikhomirov@360: 	public String getMessage() {
tikhomirov@360: 		return message;
tikhomirov@360: 	}
tikhomirov@360: 	
tikhomirov@360: 	public Exception getException() {
tikhomirov@360: 		return error;
tikhomirov@360: 	}
tikhomirov@360: }