1 package cz.xelfi.quoridor.webidor;
3 import cz.xelfi.quoridor.IllegalPositionException;
4 import cz.xelfi.quoridor.Move;
5 import java.util.ArrayList;
7 import javax.xml.bind.annotation.XmlAttribute;
8 import javax.xml.bind.annotation.XmlElement;
10 public final class CommentedMove {
15 private CommentedMove() {
19 CommentedMove(Move move, int index) {
25 public Move getMove() {
29 @XmlAttribute(name="move")
30 String getMoveText() {
31 return move.toString();
34 void setMoveText(String m) throws IllegalPositionException {
35 move = Move.valueOf(m);
43 void setIndex(int i) {
47 void addNote(Note n) {
48 if (comments == null) {
49 comments = new ArrayList<Note>();
54 @XmlElement(name="comment", required=false)
55 public final List<Note> getComments() {
59 final void setComments(List<Note> l) {
64 public String toString() {
65 StringBuilder sb = new StringBuilder();
66 sb.append("Move[").append(move).append("@").append(index);
67 if (comments != null) {
76 public boolean equals(Object obj) {
80 if (getClass() != obj.getClass()) {
83 final CommentedMove other = (CommentedMove) obj;
84 if (this.move != other.move && (this.move == null || !this.move.equals(other.move))) {
87 if (this.index != other.index) {
90 if (this.comments != other.comments && (this.comments == null || !this.comments.equals(other.comments))) {
97 public int hashCode() {
99 hash = 43 * hash + (this.move != null ? this.move.hashCode() : 0);
100 hash = 43 * hash + this.index;
101 hash = 43 * hash + (this.comments != null ? this.comments.hashCode() : 0);