blob: f690bf97d8140df1371e11c94fd8ac9b4db66090 [file] [log] [blame]
/*=========================================================================
* Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
* This product is protected by U.S. and international copyright
* and intellectual property laws. Pivotal products are covered by
* one or more patents listed at http://www.pivotal.io/patents.
*=========================================================================
*/
package com.gemstone.gemfire.pdx;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import com.gemstone.gemfire.DataSerializable;
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.pdx.PdxSerializable;
class PdxInsideDS implements DataSerializable {
private String myString1;
private long myLong;
private PdxSerializable myPdx;
private String myString2;
public PdxInsideDS() {
}
public PdxInsideDS(String str1, long myLong, PdxSerializable myPdx,
String str2) {
this.myString1 = str1;
this.myLong = myLong;
this.myPdx = myPdx;
this.myString2 = str2;
}
public void toData(DataOutput out) throws IOException {
DataSerializer.writeString(this.myString1, out);
DataSerializer.writePrimitiveLong(this.myLong, out);
DataSerializer.writeObject(this.myPdx, out);
DataSerializer.writeString(this.myString2, out);
}
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
this.myString1 = DataSerializer.readString(in);
this.myLong = DataSerializer.readPrimitiveLong(in);
this.myPdx = (PdxSerializable) DataSerializer.readObject(in);
this.myString2 = DataSerializer.readString(in);
}
@Override
public String toString() {
return "PdxInsideDS [myString1=" + myString1 + ", myLong=" + myLong
+ ", myPdx=" + myPdx + ", myString2=" + myString2 + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int)(myLong ^ (myLong >>> 32));
result = prime * result + ((myString1 == null) ? 0 : myString1.hashCode());
result = prime * result + ((myString2 == null) ? 0 : myString2.hashCode());
result = prime * result + ((myPdx == null) ? 0 : myPdx.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PdxInsideDS other = (PdxInsideDS)obj;
if (myLong != other.myLong)
return false;
if (myString1 == null) {
if (other.myString1 != null)
return false;
}
else if (!myString1.equals(other.myString1))
return false;
if (myString2 == null) {
if (other.myString2 != null)
return false;
}
else if (!myString2.equals(other.myString2))
return false;
if (myPdx == null) {
if (other.myPdx != null)
return false;
}
else if (!myPdx.equals(other.myPdx))
return false;
return true;
}
}