Skip to content

Commit

Permalink
Improve the UniqueIdentifier ser/deser.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyettinger committed Oct 17, 2024
1 parent b817bda commit 963820e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@ public UniqueIdentifierGeneratorSerializer() {

@Override
public void write(final Kryo kryo, final Output output, final UniqueIdentifier.Generator data) {
output.writeString(data.stringSerialize());
output.writeInt(data.getA());
output.writeInt(data.getB());
output.writeInt(data.getC());
output.writeInt(data.getD());
}

@Override
public UniqueIdentifier.Generator read(final Kryo kryo, final Input input, final Class<? extends UniqueIdentifier.Generator> dataClass) {
return new UniqueIdentifier.Generator().stringDeserialize(input.readString());
return new UniqueIdentifier.Generator(input.readInt(), input.readInt(), input.readInt(), input.readInt());
}

@Override
public UniqueIdentifier.Generator copy(Kryo kryo, UniqueIdentifier.Generator original) {
return new UniqueIdentifier.Generator(original.getA(), original.getB(), original.getC(), original.getD());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ public UniqueIdentifierSerializer() {

@Override
public void write(final Kryo kryo, final Output output, final UniqueIdentifier data) {
output.writeLong(data.getHi());
output.writeLong(data.getLo());
output.writeInt(data.getA());
output.writeInt(data.getB());
output.writeInt(data.getC());
output.writeInt(data.getD());
}

@Override
public UniqueIdentifier read(final Kryo kryo, final Input input, final Class<? extends UniqueIdentifier> dataClass) {
return new UniqueIdentifier(input.readLong(), input.readLong());
return new UniqueIdentifier(input.readInt(), input.readInt(), input.readInt(), input.readInt());
}

@Override
public UniqueIdentifier copy(Kryo kryo, UniqueIdentifier original) {
return new UniqueIdentifier(original.getHi(), original.getLo());
return new UniqueIdentifier(original.getA(), original.getB(), original.getC(), original.getD());
}
}

0 comments on commit 963820e

Please sign in to comment.