]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
0516838ad68dc6e7d95d259dac5d242ef8ede790
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2    Copyright 2010 Sun Microsystems, Inc.
3    All rights reserved. Use is subject to license terms.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; version 2 of the License.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
17 */
18
19 package com.mysql.clusterj.jpatest.model;
20
21 import java.io.Serializable;
22 import java.io.ObjectInputStream;
23 import java.io.ObjectOutputStream;
24 import java.io.IOException;
25 import java.util.Collection;
26 import java.util.HashSet;
27
28 /**
29  * An Entity test class.
30  */
31 @javax.persistence.Entity
32 @javax.persistence.Table(name="a")
33 public class A implements Serializable {
34     // @Basic(fetch=EAGER) is the default mapping annotation
35     // for primitive types, wrappers, String...
36
37     // required for serialization
38     static private final long serialVersionUID = -3359921162347129079L;
39
40     @javax.persistence.Id
41     private int id;
42
43     private int cint;
44     
45     private long clong;
46     
47     private float cfloat;
48     
49     private double cdouble;
50     
51     private String cstring;
52     
53     @javax.persistence.OneToMany(mappedBy="a")
54     private Collection<B0> b0s = new HashSet<B0>();
55     
56     public A() {
57     }
58
59     // XXX ....
60     static public A create(int id) {
61         A o = new A();
62         o.setId(id);
63         o.setCint((int)id);
64         o.setClong((long)id);
65         o.setCfloat((float)id);
66         o.setCdouble((double)id);
67         o.setCstring(String.valueOf(id));
68         return o;
69     }
70
71     public int getId() {
72         return id;
73     }
74     
75     public void setId(int id) {
76         this.id = id;
77     }
78     
79     public int getCint() {
80         return cint;
81     }
82     
83     public void setCint(int cint) {
84         this.cint = cint;
85     }
86     
87     public long getClong() {
88         return clong;
89     }
90     
91     public void setClong(long clong) {
92         this.clong = clong;
93     }
94     
95     public float getCfloat() {
96         return cfloat;
97     }
98     
99     public void setCfloat(float cfloat) {
100         this.cfloat = cfloat;
101     }
102     
103     public double getCdouble() {
104         return cdouble;
105     }
106     
107     public void setCdouble(double cdouble) {
108         this.cdouble = cdouble;
109     }
110     
111     public String getCstring() {
112         return cstring;
113     }
114     
115     public void setCstring(String cstring) {
116         this.cstring = cstring;
117     }
118     
119     public Collection<B0> getB0s() {
120         return b0s;
121     }
122     
123     public void setB0s(Collection<B0> b0s) {
124         this.b0s = b0s;
125     }
126     
127     private void writeObject(ObjectOutputStream out) throws IOException {
128         out.defaultWriteObject();
129     }
130     
131     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
132         in.defaultReadObject();
133     }
134     
135     static public class Oid implements Serializable {
136         
137         public int id;
138         
139         public Oid() {
140         }
141         
142         @Override
143         public boolean equals(Object obj) {
144             if (obj == null || !this.getClass().equals(obj.getClass()))
145                 return false;
146             Oid o = (Oid)obj;
147             return (this.id == o.id);
148         }
149         
150         @Override
151         public int hashCode() {
152             return id;
153         }        
154     }    
155
156     @Override
157     public String toString() {
158         StringBuffer buffer = new StringBuffer();
159         buffer.append("A id: ");
160         buffer.append(id);
161         buffer.append("; cint: ");
162         buffer.append(cint);
163         buffer.append("; clong: ");
164         buffer.append(clong);
165         buffer.append("; cfloat: ");
166         buffer.append(cfloat);
167         buffer.append("; cdouble: ");
168         buffer.append(cdouble);
169         buffer.append("; cstring: ");
170         buffer.append(cstring);
171         buffer.append("; collection<b0>(");
172         int size = b0s.size();
173         buffer.append(size);
174         buffer.append("): [");
175         String separator = "";
176         for (B0 b: b0s) {
177             buffer.append(separator);
178             buffer.append (b.getId());
179             separator = "; ";
180         }
181         buffer.append("]");
182         return buffer.toString();
183     }
184
185 }
186