Merge "BUG-972: correct Precondition"
[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 static final long serialVersionUID = 1L;
16     private String mystring;
17
18     public StringContainer() {
19         this.mystring = null;
20     }
21
22     public StringContainer(String s) {
23         setMystring(s);
24     }
25
26     public String getMystring() {
27         return mystring;
28     }
29
30     public void setMystring(String mystring) {
31         this.mystring = mystring;
32     }
33
34     // Return the hashCode of the containing string
35     @Override
36     public int hashCode() {
37         if (this.mystring != null) {
38             return this.mystring.hashCode();
39         }
40         return 0;
41     }
42
43     @Override
44     public boolean equals(Object obj) {
45         if (obj instanceof StringContainer) {
46             StringContainer o = (StringContainer) obj;
47             return this.mystring.equals(o.getMystring());
48         }
49         return false;
50     }
51
52     @Override
53     public String toString() {
54         return "{" + this.mystring + "}";
55     }
56 }