Skip to content

Conversation

jeremyplichta
Copy link
Collaborator

Added new spel functions parseHex and parseUuid

To complete before merge:

  • test locally with local redis instance
  • add unit/integration tests

@jeremyplichta jeremyplichta requested a review from jruaux March 20, 2025 03:53
@jruaux
Copy link
Collaborator

jruaux commented Mar 20, 2025

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());
	}

@jeremyplichta
Copy link
Collaborator Author

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());
	}

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants