OSDN Git Service

Delete Subversion Tags (Revision, Id)
[stigmata/stigmata.git] / src / main / java / jp / sourceforge / stigmata / BirthmarkElement.java
1 package jp.sourceforge.stigmata;
2
3 import java.io.Serializable;
4
5 /**
6  * element of birthmark.
7  * 
8  * @author  Haruaki TAMADA
9  */
10 public class BirthmarkElement implements Serializable{
11     private static final long serialVersionUID = 943675475343245243L;
12
13     /**
14      * element value.
15      */
16     private String value;
17
18     /**
19      * construct birthmark element with given value. 
20      */
21     public BirthmarkElement(String value) {
22         this.value = value;
23     }
24
25     /**
26      * return the value of this element.
27      */
28     public Object getValue(){
29         return value;
30     }
31
32     /**
33      * to string.
34      */
35     @Override
36     public String toString(){
37         return String.valueOf(getValue());
38     }
39
40     /**
41      * hash code for overriding equals method.
42      */
43     @Override
44     public int hashCode(){
45         if(getValue() == null){
46             return 0;
47         }
48         else{
49             return getValue().hashCode();
50         }
51     }
52
53     /**
54      * equals method.
55      */
56     @Override
57     public boolean equals(Object o){
58         if(o instanceof BirthmarkElement){
59             if(getValue() != null){
60                 return getValue().equals(((BirthmarkElement)o).getValue());
61             }
62             else{
63                 return ((BirthmarkElement)o).getValue() == null;
64             }
65         }
66         return false;
67     }
68 }