Created
October 9, 2015 09:44
-
-
Save danielshaya/b804bbb6212d2fa8342a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package chronicle.demo; | |
import net.openhft.chronicle.bytes.IORuntimeException; | |
import net.openhft.chronicle.wire.Marshallable; | |
import net.openhft.chronicle.wire.WireIn; | |
import net.openhft.chronicle.wire.WireOut; | |
/** | |
* Created by daniel on 08/10/2015. | |
*/ | |
public class Person implements Marshallable { | |
private String name; | |
private int age; | |
public Person() { | |
} | |
public Person(String name, int age) { | |
this.name = name; | |
this.age = age; | |
} | |
@Override | |
public void readMarshallable(WireIn wireIn) throws IORuntimeException { | |
wireIn.read(() -> "name").text(this, (o, b) -> o.name = b) | |
.read(() -> "age").int8(this, (o, b) -> o.age = b); | |
} | |
@Override | |
public void writeMarshallable(WireOut wireOut) { | |
wireOut.write(() -> "name").text(name) | |
.write(() -> "age").int8(age); | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public void setAge(int age) { | |
this.age = age; | |
} | |
@Override | |
public String toString() { | |
return "Person{" + | |
"name='" + name + '\'' + | |
", age=" + age + | |
'}'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment