1.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/CommentedMove.java Sun Sep 05 22:34:43 2010 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,104 +0,0 @@
1.4 -package cz.xelfi.quoridor.webidor;
1.5 -
1.6 -import cz.xelfi.quoridor.IllegalPositionException;
1.7 -import cz.xelfi.quoridor.Move;
1.8 -import java.util.ArrayList;
1.9 -import java.util.List;
1.10 -import javax.xml.bind.annotation.XmlAttribute;
1.11 -import javax.xml.bind.annotation.XmlElement;
1.12 -
1.13 -public final class CommentedMove {
1.14 - Move move;
1.15 - int index;
1.16 - List<Note> comments;
1.17 -
1.18 - private CommentedMove() {
1.19 - super();
1.20 - }
1.21 -
1.22 - CommentedMove(Move move, int index) {
1.23 - super();
1.24 - this.move = move;
1.25 - this.index = index;
1.26 - }
1.27 -
1.28 - public Move getMove() {
1.29 - return move;
1.30 - }
1.31 -
1.32 - @XmlAttribute(name="move")
1.33 - String getMoveText() {
1.34 - return move.toString();
1.35 - }
1.36 -
1.37 - void setMoveText(String m) throws IllegalPositionException {
1.38 - move = Move.valueOf(m);
1.39 - }
1.40 -
1.41 - @XmlAttribute
1.42 - int getIndex() {
1.43 - return index;
1.44 - }
1.45 -
1.46 - void setIndex(int i) {
1.47 - index = i;
1.48 - }
1.49 -
1.50 - void addNote(Note n) {
1.51 - if (comments == null) {
1.52 - comments = new ArrayList<Note>();
1.53 - }
1.54 - comments.add(n);
1.55 - }
1.56 -
1.57 - @XmlElement(name="comment", required=false)
1.58 - public final List<Note> getComments() {
1.59 - return comments;
1.60 - }
1.61 -
1.62 - final void setComments(List<Note> l) {
1.63 - this.comments = l;
1.64 - }
1.65 -
1.66 - @Override
1.67 - public String toString() {
1.68 - StringBuilder sb = new StringBuilder();
1.69 - sb.append("Move[").append(move).append("@").append(index);
1.70 - if (comments != null) {
1.71 - sb.append(", ");
1.72 - sb.append(comments);
1.73 - }
1.74 - sb.append("]");
1.75 - return sb.toString();
1.76 - }
1.77 -
1.78 - @Override
1.79 - public boolean equals(Object obj) {
1.80 - if (obj == null) {
1.81 - return false;
1.82 - }
1.83 - if (getClass() != obj.getClass()) {
1.84 - return false;
1.85 - }
1.86 - final CommentedMove other = (CommentedMove) obj;
1.87 - if (this.move != other.move && (this.move == null || !this.move.equals(other.move))) {
1.88 - return false;
1.89 - }
1.90 - if (this.index != other.index) {
1.91 - return false;
1.92 - }
1.93 - if (this.comments != other.comments && (this.comments == null || !this.comments.equals(other.comments))) {
1.94 - return false;
1.95 - }
1.96 - return true;
1.97 - }
1.98 -
1.99 - @Override
1.100 - public int hashCode() {
1.101 - int hash = 5;
1.102 - hash = 43 * hash + (this.move != null ? this.move.hashCode() : 0);
1.103 - hash = 43 * hash + this.index;
1.104 - hash = 43 * hash + (this.comments != null ? this.comments.hashCode() : 0);
1.105 - return hash;
1.106 - }
1.107 -}