Skip to content

Commit

Permalink
Fixes deserialization of UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed May 6, 2023
1 parent b060fb6 commit 3e204c6
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ public UUID asUUID() {
}
private static UUID parseUUID(Object obj) {
if (obj instanceof Collection) {
Iterator<Long> i = ((Collection<Long>) obj).iterator();
return new UUID(i.next(), i.next());
Iterator<Number> i = ((Collection<Number>) obj).iterator();
return new UUID(i.next().longValue(), i.next().longValue());
} else if (obj != null) {
return UUID.fromString(obj.toString());
} else {
Expand Down Expand Up @@ -341,7 +341,16 @@ public boolean isString() {
* @return UUID Status
*/
public boolean isUUID() {
return ((obj instanceof List && Try.all.run(() -> asLongList().get(1).longValue())) || (obj instanceof String && Try.all.run(() -> UUID.fromString(asString()))));
if (obj instanceof Collection) {
Iterator<Number> i = ((Collection<Number>) obj).iterator();
if (i.hasNext()) {
i.next();
return i.hasNext();
}
} else if (obj instanceof String) {
return true;
}
return false;
}

@Override
Expand Down

0 comments on commit 3e204c6

Please sign in to comment.