Bug 809: Enhancements to the toaster example
[controller.git] / opendaylight / clustering / test / src / main / java / org / opendaylight / controller / clustering / test / internal / StringContainer.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.clustering.test.internal;
11
12 import java.io.Serializable;
13
14 public class StringContainer implements Serializable {
15     private String mystring;
16
17     public StringContainer() {
18         this.mystring = null;
19     }
20
21     public StringContainer(String s) {
22         setMystring(s);
23     }
24
25     public String getMystring() {
26         return mystring;
27     }
28
29     public void setMystring(String mystring) {
30         this.mystring = mystring;
31     }
32
33     // Return the hashCode of the containing string
34     @Override
35     public int hashCode() {
36         if (this.mystring != null) {
37             return this.mystring.hashCode();
38         }
39         return 0;
40     }
41
42     @Override
43     public boolean equals(Object obj) {
44         if (obj instanceof StringContainer) {
45             StringContainer o = (StringContainer) obj;
46             return this.mystring.equals(o.getMystring());
47         }
48         return false;
49     }
50
51     @Override
52     public String toString() {
53         return "{" + this.mystring + "}";
54     }
55 }