2 * Quoridor server and related libraries
3 * Copyright (C) 2009-2010 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://www.gnu.org/licenses/.
19 package cz.xelfi.quoridor.webidor;
21 import cz.xelfi.quoridor.IllegalPositionException;
22 import cz.xelfi.quoridor.Move;
23 import java.util.ArrayList;
24 import java.util.List;
25 import javax.xml.bind.annotation.XmlAttribute;
26 import javax.xml.bind.annotation.XmlElement;
28 public final class CommentedMove {
33 private CommentedMove() {
37 CommentedMove(Move move, int index) {
43 public Move getMove() {
47 @XmlAttribute(name="move")
48 String getMoveText() {
49 return move.toString();
52 void setMoveText(String m) throws IllegalPositionException {
53 move = Move.valueOf(m);
61 void setIndex(int i) {
65 void addNote(Note n) {
66 if (comments == null) {
67 comments = new ArrayList<Note>();
72 @XmlElement(name="comment", required=false)
73 public final List<Note> getComments() {
77 final void setComments(List<Note> l) {
82 public String toString() {
83 StringBuilder sb = new StringBuilder();
84 sb.append("Move[").append(move).append("@").append(index);
85 if (comments != null) {
94 public boolean equals(Object obj) {
98 if (getClass() != obj.getClass()) {
101 final CommentedMove other = (CommentedMove) obj;
102 if (this.move != other.move && (this.move == null || !this.move.equals(other.move))) {
105 if (this.index != other.index) {
108 if (this.comments != other.comments && (this.comments == null || !this.comments.equals(other.comments))) {
115 public int hashCode() {
117 hash = 43 * hash + (this.move != null ? this.move.hashCode() : 0);
118 hash = 43 * hash + this.index;
119 hash = 43 * hash + (this.comments != null ? this.comments.hashCode() : 0);