wsdor/src/main/java/cz/xelfi/quoridor/webidor/Note.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 11 Sep 2010 17:04:51 +0200
changeset 256 1758a7727278
parent 115 webidor/src/main/java/cz/xelfi/quoridor/webidor/Note.java@6a80463a74c0
child 266 15fcdfc4cd4a
permissions -rw-r--r--
Splitting classes representing data types on the server into own module
     1 package cz.xelfi.quoridor.webidor;
     2 
     3 import java.util.Date;
     4 import javax.xml.bind.annotation.XmlAccessType;
     5 import javax.xml.bind.annotation.XmlAccessorType;
     6 import javax.xml.bind.annotation.XmlAttribute;
     7 import javax.xml.bind.annotation.XmlValue;
     8 
     9 /**
    10  *
    11  * @author Jaroslav Tulach <jtulach@netbeans.org>
    12  */
    13 @XmlAccessorType(XmlAccessType.FIELD)
    14 public class Note {
    15     @XmlValue
    16     private String comment;
    17     @XmlAttribute
    18     private Date when;
    19     @XmlAttribute
    20     private String who;
    21 
    22     private Note() {
    23     }
    24 
    25     public Note(String comment, Date when, String who) {
    26         this.comment = comment;
    27         this.when = new Date(when.getTime());
    28         this.who = who;
    29     }
    30 
    31     public String getComment() {
    32         return comment;
    33     }
    34 
    35     public Date getWhen() {
    36         return (Date) when.clone();
    37     }
    38 
    39     public String getWho() {
    40         return who;
    41     }
    42 
    43     @Override
    44     public String toString() {
    45         return "Note[" + who + "@" + when + ": " + comment + "]";
    46     }
    47 
    48     @Override
    49     public boolean equals(Object obj) {
    50         if (obj == null) {
    51             return false;
    52         }
    53         if (getClass() != obj.getClass()) {
    54             return false;
    55         }
    56         final Note other = (Note) obj;
    57         if ((this.comment == null) ? (other.comment != null) : !this.comment.equals(other.comment)) {
    58             return false;
    59         }
    60         if (this.when != other.when && (this.when == null || !this.when.equals(other.when))) {
    61             return false;
    62         }
    63         if ((this.who == null) ? (other.who != null) : !this.who.equals(other.who)) {
    64             return false;
    65         }
    66         return true;
    67     }
    68 
    69     @Override
    70     public int hashCode() {
    71         int hash = 7;
    72         hash = 59 * hash + (this.comment != null ? this.comment.hashCode() : 0);
    73         hash = 59 * hash + (this.when != null ? this.when.hashCode() : 0);
    74         hash = 59 * hash + (this.who != null ? this.who.hashCode() : 0);
    75         return hash;
    76     }
    77 
    78 
    79 }