![JAR search and dependency download from the Maven repository](/logo.png)
com.gemstone.gemfire.pdx.SimpleClass Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gemfire-junit Show documentation
Show all versions of gemfire-junit Show documentation
SnappyData store based off Pivotal GemFireXD
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.pdx;
public class SimpleClass implements PdxSerializable {
public static enum SimpleEnum {ONE, TWO};
private int myInt;
private byte myByte;
private SimpleEnum myEnum;
public SimpleClass() {
}
public SimpleClass(int intVal, byte byteVal) {
this.myInt = intVal;
this.myByte = byteVal;
this.myEnum = SimpleEnum.TWO;
}
public SimpleClass(int intVal, byte byteVal, SimpleEnum enumVal) {
this.myInt = intVal;
this.myByte = byteVal;
this.myEnum = enumVal;
}
public void toData(PdxWriter out) {
out.writeInt("myInt", this.myInt);
out.writeByte("myByte", this.myByte);
out.writeObject("myEnum", this.myEnum);
}
public void fromData(PdxReader in){
this.myInt = in.readInt("myInt");
this.myByte = in.readByte("myByte");
this.myEnum = (SimpleEnum) in.readObject("myEnum");
}
@Override
public String toString() {
return getClass().getSimpleName() + " [myInt=" + myInt + ", myByte=" + myByte + ", myEnum=" + myEnum + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + myByte;
result = prime * result + ((myEnum == null) ? 0 : myEnum.hashCode());
result = prime * result + myInt;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SimpleClass other = (SimpleClass) obj;
if (myByte != other.myByte)
return false;
if (myEnum != other.myEnum)
return false;
if (myInt != other.myInt)
return false;
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy