frostfs-sdk-java/models/src/main/java/info/FrostFS/sdk/UUIDExtension.java
Bruk Ori b0db7df192 [#1] add client environment
add client cut
code cleanup
Signed-off-by: Ori Bruk <o.bruk@yadro.com>
2024-07-24 15:49:12 +03:00

21 lines
564 B
Java

package info.FrostFS.sdk;
import java.nio.ByteBuffer;
import java.util.UUID;
public class UUIDExtension {
public static UUID asUuid(byte[] bytes) {
ByteBuffer bb = ByteBuffer.wrap(bytes);
long firstLong = bb.getLong();
long secondLong = bb.getLong();
return new UUID(firstLong, secondLong);
}
public static byte[] asBytes(UUID id) {
ByteBuffer bb = ByteBuffer.allocate(16);
bb.putLong(id.getMostSignificantBits());
bb.putLong(id.getLeastSignificantBits());
return bb.array();
}
}