add parseHex and parseUuid spel functions to return byte arrays
Added new spel functions parseHex and parseUuid
To complete before merge:
- [x] test locally with local redis instance
- [ ] add unit/integration tests
Could we use jakarta.xml.bind.DataTypeConverter.parseHexBinary(String hex) for the hex parser?
Also we could probably simplify parseUuid with java.nio.ByteBuffer:
public static String parseUuid(String uuid) {
if (uuid == null) {
return null;
}
UUID uuidObj = UUID.fromString(uuid);
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuidObj.getMostSignificantBits());
bb.putLong(uuidObj.getLeastSignificantBits());
return new String(bb.array());
}
Could we use
jakarta.xml.bind.DataTypeConverter.parseHexBinary(String hex)for the hex parser?Also we could probably simplify
parseUuidwithjava.nio.ByteBuffer:public static String parseUuid(String uuid) { if (uuid == null) { return null; } UUID uuidObj = UUID.fromString(uuid); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuidObj.getMostSignificantBits()); bb.putLong(uuidObj.getLeastSignificantBits()); return new String(bb.array()); }
Thanks, those are good suggestions. I will make those when I have a chance as well as implement some tests for this to make sure that we are not having any character encode issues going from byte to string. I'll ping you on here for another review when I'm ready. Thanks!