webidor/src/main/java/cz/xelfi/quoridor/webidor/GameId.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 30 Aug 2009 14:37:47 +0200
changeset 48 69e897fe8140
child 54 f041b6570ff9
permissions -rw-r--r--
Spliting Game into GameId and Game with full info about the state of the game
jaroslav@48
     1
/*
jaroslav@48
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
jaroslav@48
     3
 *
jaroslav@48
     4
 * The contents of this file are subject to the terms of either the GNU
jaroslav@48
     5
 * General Public License Version 2 only ("GPL") or the Common
jaroslav@48
     6
 * Development and Distribution License("CDDL") (collectively, the
jaroslav@48
     7
 * "License"). You may not use this file except in compliance with the
jaroslav@48
     8
 * License. You can obtain a copy of the License at
jaroslav@48
     9
 * http://www.netbeans.org/cddl-gplv2.html
jaroslav@48
    10
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
jaroslav@48
    11
 * specific language governing permissions and limitations under the
jaroslav@48
    12
 * License.  When distributing the software, include this License Header
jaroslav@48
    13
 * Notice in each file and include the License file at
jaroslav@48
    14
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
jaroslav@48
    15
 * particular file as subject to the "Classpath" exception as provided
jaroslav@48
    16
 * by Sun in the GPL Version 2 section of the License file that
jaroslav@48
    17
 * accompanied this code. If applicable, add the following below the
jaroslav@48
    18
 * License Header, with the fields enclosed by brackets [] replaced by
jaroslav@48
    19
 * your own identifying information:
jaroslav@48
    20
 * "Portions Copyrighted [year] [name of copyright owner]"
jaroslav@48
    21
 *
jaroslav@48
    22
 * Contributor(s):
jaroslav@48
    23
 *
jaroslav@48
    24
 * Portions Copyrighted 2009 Jaroslav Tulach
jaroslav@48
    25
 */
jaroslav@48
    26
jaroslav@48
    27
package cz.xelfi.quoridor.webidor;
jaroslav@48
    28
jaroslav@48
    29
import java.util.Date;
jaroslav@48
    30
import java.util.UUID;
jaroslav@48
    31
import javax.xml.bind.annotation.XmlAccessType;
jaroslav@48
    32
import javax.xml.bind.annotation.XmlAccessorType;
jaroslav@48
    33
import javax.xml.bind.annotation.XmlAttribute;
jaroslav@48
    34
import javax.xml.bind.annotation.XmlID;
jaroslav@48
    35
import javax.xml.bind.annotation.XmlRootElement;
jaroslav@48
    36
jaroslav@48
    37
/** Basic identification of a game.
jaroslav@48
    38
 *
jaroslav@48
    39
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@48
    40
 */
jaroslav@48
    41
@XmlRootElement
jaroslav@48
    42
@XmlAccessorType(XmlAccessType.FIELD)
jaroslav@48
    43
public class GameId {
jaroslav@48
    44
    @XmlAttribute
jaroslav@48
    45
    private String white;
jaroslav@48
    46
    @XmlAttribute
jaroslav@48
    47
    private String black;
jaroslav@48
    48
    @XmlAttribute
jaroslav@48
    49
    private Date started;
jaroslav@48
    50
    @XmlAttribute
jaroslav@48
    51
    private GameResult result;
jaroslav@48
    52
    @XmlID
jaroslav@48
    53
    private String id;
jaroslav@48
    54
jaroslav@48
    55
    GameId() {
jaroslav@48
    56
    }
jaroslav@48
    57
jaroslav@48
    58
    public GameId(String first, String second) {
jaroslav@48
    59
        this(
jaroslav@48
    60
            UUID.randomUUID().toString(),
jaroslav@48
    61
            first, second, new Date(), GameResult.IN_PROGRESS
jaroslav@48
    62
        );
jaroslav@48
    63
    }
jaroslav@48
    64
jaroslav@48
    65
    public GameId(String id, String first, String second, Date started, GameResult result) {
jaroslav@48
    66
        this.white = first;
jaroslav@48
    67
        this.black = second;
jaroslav@48
    68
        this.id = id;
jaroslav@48
    69
        this.started = started;
jaroslav@48
    70
        this.result = result;
jaroslav@48
    71
    }
jaroslav@48
    72
jaroslav@48
    73
    public String getId() {
jaroslav@48
    74
        return id;
jaroslav@48
    75
    }
jaroslav@48
    76
jaroslav@48
    77
    public String getWhite() {
jaroslav@48
    78
        return white;
jaroslav@48
    79
    }
jaroslav@48
    80
jaroslav@48
    81
    public String getBlack() {
jaroslav@48
    82
        return black;
jaroslav@48
    83
    }
jaroslav@48
    84
jaroslav@48
    85
    public Date getStarted() {
jaroslav@48
    86
        return started;
jaroslav@48
    87
    }
jaroslav@48
    88
jaroslav@48
    89
    public GameResult getResult() {
jaroslav@48
    90
        return result;
jaroslav@48
    91
    }
jaroslav@48
    92
}