Code Examples
A repository of 155 code examples for BeepBeep
CompoundObject.java
1 /*
2  BeepBeep, an event stream processor
3  Copyright (C) 2008-2017 Sylvain HallĂ©
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published
7  by the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package network;
19 
20 /**
21  * A dummy object used to show serialization. This class is used in the
22  * examples of this package as the type of events to be transmitted over
23  * the network.
24  */
25 public class CompoundObject
26 {
27  int a;
28  String b;
30 
31  protected CompoundObject()
32  {
33  super();
34  }
35 
36  ///
37  public CompoundObject(int a, String b, CompoundObject c)
38  {
39  super();
40  this.a = a;
41  this.b = b;
42  this.c = c;
43  }
44 
45  @Override
46  public String toString()
47  {
48  return "a = " + a + ", b = " + b + ", c = (" + c + ")";
49  }
50  ///
51 
52  @Override
53  public boolean equals(Object o)
54  {
55  if (o == null || !(o instanceof CompoundObject))
56  {
57  return false;
58  }
59  CompoundObject co = (CompoundObject) o;
60  if (this.a != co.a || this.b.compareTo(co.b) != 0)
61  {
62  return false;
63  }
64  if ((this.c == null && co.c == null) || (this.c != null && co.c != null && this.c.equals(co.c)))
65  {
66  return true;
67  }
68  return false;
69  }
70 }
A dummy object used to show serialization.