diff --git a/guid/src/main/java/com/onixbyte/guid/impl/SequentialUuidCreator.java b/guid/src/main/java/com/onixbyte/guid/impl/SequentialUuidCreator.java new file mode 100644 index 0000000..309837d --- /dev/null +++ b/guid/src/main/java/com/onixbyte/guid/impl/SequentialUuidCreator.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2024-2025 OnixByte. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.onixbyte.guid.impl; + +import com.onixbyte.guid.GuidCreator; + +import java.nio.ByteBuffer; +import java.security.SecureRandom; +import java.util.UUID; + +/** + * A {@code SequentialUuidCreator} is responsible for generating UUIDs following the UUID version 7 specification, which + * combines a timestamp with random bytes to create time-ordered unique identifiers. + *
+ * This implementation utilises a cryptographically strong {@link SecureRandom} instance to produce the random + * component of the UUID. The first 6 bytes of the UUID encode the current timestamp in milliseconds, ensuring that + * generated UUIDs are roughly ordered by creation time. + *
+ * The generated UUID adheres strictly to the layout and variant bits of UUID version 7 as defined in the specification. + *
+ * + * @implNote This class implements the {@link GuidCreator} interface, providing UUID instances as unique identifiers. + */ +public class SequentialUuidCreator implements GuidCreator