Skip to content

Instantly share code, notes, and snippets.

@enragedginger
Created March 8, 2014 21:42
Show Gist options
  • Save enragedginger/9439325 to your computer and use it in GitHub Desktop.
Save enragedginger/9439325 to your computer and use it in GitHub Desktop.
Sample Stephenerialization Class
@Stephenerializable(version=20121001)
public class Sandwich implements Serializable {
private static final long serialVersionUID = 1L;
@Stephenerialize(minVersion=20120926, priority=1)
private int slicesOfBread;
@Stephenerialize(minVersion=20120926, priority=2)
private byte sesameSeeds;
@Stephenerialize(minVersion=20120927, priority=1)
private short slicesOfMeat;
@Stephenerialize(minVersion=20120927, priority=2)
private long molecules;
@Stephenerialize(minVersion=20120928, priority=1)
private double price;
@Stephenerialize(minVersion=20120928, priority=2)
private char size;
@Stephenerialize(minVersion=20121001, priority=1)
private String name;
//... getters and setters ommitted for brevity
/**
* Writes this object out to the stream using Stephenerialization.
* @param streamer The output stream to use.
*/
private void writeObject(ObjectOutputStream streamer) {
final StephenerializationService service = StephenerializationLookupService.lookup();
service.stephenerialize(this, streamer, Sandwich.class);
}
/**
* Reads this object from the stream using Stephenerialization.
* @param streamer The input stream to use.
*/
private void readObject(ObjectInputStream streamer) {
final StephenerializationService service = StephenerializationLookupService.lookup();
service.destephenerialize(this, streamer, Sandwich.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment