From 77f69b7f77b3dd308f14d6db19e7c1046a1a3292 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Sat, 6 Jul 2024 19:54:19 -0300 Subject: [PATCH] Rename StringCodec and BinaryCodec Changes: * BinaryCodec -> StandardBinaryCodec * StringCodec -> StandardStringCodec --- .../com/github/f4b6a3/uuid/UuidCreator.java | 12 ++--- ...aryCodec.java => StandardBinaryCodec.java} | 6 ++- ...ingCodec.java => StandardStringCodec.java} | 25 +++++----- .../github/f4b6a3/uuid/codec/UriCodec.java | 2 +- .../github/f4b6a3/uuid/codec/UrnCodec.java | 4 +- .../f4b6a3/uuid/codec/other/NcnameCodec.java | 10 ++-- .../f4b6a3/uuid/factory/UuidFactory.java | 8 ++-- .../f4b6a3/uuid/codec/BinaryCodecTest.java | 10 ++-- .../f4b6a3/uuid/codec/StringCodecTest.java | 16 +++---- .../uuid/codec/base/BaseNCodec1Test.java | 4 +- .../function/BaseNRemainderDecoderTest.java | 8 ++-- .../function/BaseNRemainderEncoderTest.java | 4 +- .../uuid/codec/other/SlugCodecTest.java | 4 +- .../f4b6a3/uuid/factory/UuidFactoryTest.java | 4 +- .../f4b6a3/uuid/util/UuidComparatorTest.java | 46 +++++++++---------- 15 files changed, 84 insertions(+), 79 deletions(-) rename src/main/java/com/github/f4b6a3/uuid/codec/{BinaryCodec.java => StandardBinaryCodec.java} (93%) rename src/main/java/com/github/f4b6a3/uuid/codec/{StringCodec.java => StandardStringCodec.java} (90%) diff --git a/src/main/java/com/github/f4b6a3/uuid/UuidCreator.java b/src/main/java/com/github/f4b6a3/uuid/UuidCreator.java index 1292012d..c9083f53 100644 --- a/src/main/java/com/github/f4b6a3/uuid/UuidCreator.java +++ b/src/main/java/com/github/f4b6a3/uuid/UuidCreator.java @@ -32,8 +32,8 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.function.Supplier; -import com.github.f4b6a3.uuid.codec.BinaryCodec; -import com.github.f4b6a3.uuid.codec.StringCodec; +import com.github.f4b6a3.uuid.codec.StandardBinaryCodec; +import com.github.f4b6a3.uuid.codec.StandardStringCodec; import com.github.f4b6a3.uuid.enums.UuidLocalDomain; import com.github.f4b6a3.uuid.enums.UuidNamespace; import com.github.f4b6a3.uuid.exception.InvalidUuidException; @@ -135,7 +135,7 @@ public static UUID getMax() { * @throws InvalidUuidException if the argument is invalid */ public static byte[] toBytes(final UUID uuid) { - return BinaryCodec.INSTANCE.encode(uuid); + return StandardBinaryCodec.INSTANCE.encode(uuid); } /** @@ -148,7 +148,7 @@ public static byte[] toBytes(final UUID uuid) { * @throws InvalidUuidException if the argument is invalid */ public static UUID fromBytes(byte[] uuid) { - return BinaryCodec.INSTANCE.decode(uuid); + return StandardBinaryCodec.INSTANCE.decode(uuid); } /** @@ -161,7 +161,7 @@ public static UUID fromBytes(byte[] uuid) { * @throws InvalidUuidException if the argument is invalid */ public static String toString(UUID uuid) { - return StringCodec.INSTANCE.encode(uuid); + return StandardStringCodec.INSTANCE.encode(uuid); } /** @@ -184,7 +184,7 @@ public static String toString(UUID uuid) { * @throws InvalidUuidException if the argument is invalid */ public static UUID fromString(String uuid) { - return StringCodec.INSTANCE.decode(uuid); + return StandardStringCodec.INSTANCE.decode(uuid); } /** diff --git a/src/main/java/com/github/f4b6a3/uuid/codec/BinaryCodec.java b/src/main/java/com/github/f4b6a3/uuid/codec/StandardBinaryCodec.java similarity index 93% rename from src/main/java/com/github/f4b6a3/uuid/codec/BinaryCodec.java rename to src/main/java/com/github/f4b6a3/uuid/codec/StandardBinaryCodec.java index 1614804d..c2a0292d 100644 --- a/src/main/java/com/github/f4b6a3/uuid/codec/BinaryCodec.java +++ b/src/main/java/com/github/f4b6a3/uuid/codec/StandardBinaryCodec.java @@ -33,13 +33,15 @@ * Codec for UUID binary encoding as defined in the RFC-4122. *

* The UUID is encoded as 16 octets (bytes). + *

+ * Read: https://www.rfc-editor.org/rfc/rfc9562.html#name-uuid-format */ -public class BinaryCodec implements UuidCodec { +public class StandardBinaryCodec implements UuidCodec { /** * A shared immutable instance. */ - public static final BinaryCodec INSTANCE = new BinaryCodec(); + public static final StandardBinaryCodec INSTANCE = new StandardBinaryCodec(); /** * Get an array of bytes from a UUID. diff --git a/src/main/java/com/github/f4b6a3/uuid/codec/StringCodec.java b/src/main/java/com/github/f4b6a3/uuid/codec/StandardStringCodec.java similarity index 90% rename from src/main/java/com/github/f4b6a3/uuid/codec/StringCodec.java rename to src/main/java/com/github/f4b6a3/uuid/codec/StandardStringCodec.java index e048fabf..c3c11669 100644 --- a/src/main/java/com/github/f4b6a3/uuid/codec/StringCodec.java +++ b/src/main/java/com/github/f4b6a3/uuid/codec/StandardStringCodec.java @@ -33,34 +33,37 @@ import com.github.f4b6a3.uuid.util.internal.JavaVersionUtil; /** - * Codec for UUID string representation as defined in RFC-4122. + * Codec for UUID canonical string as defined in RFC-4122. *

- * The string representation, also referred as canonical textual representation, - * is a string of 32 hexadecimal (base-16) digits, displayed in five groups + * In the canonical textual representation, the 16 bytes of a UUID are + * represented as 32 hexadecimal (base-16) digits, displayed in five groups * separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 * hexadecimal characters and 4 hyphens). *

- * This codec decodes (parses) strings in these formats, with/without hyphens: + * This codec decodes (parses) strings in these formats: *

*

* The encoding and decoding processes can be much faster (7x) than * {@link UUID#toString()} and {@link UUID#fromString(String)} in JDK 8. *

* If you prefer a string representation without hyphens, use - * {@link Base16Codec} instead of {@link StringCodec}. {@link Base16Codec} can - * be much faster (22x) than doing + * {@link Base16Codec} instead of {@link StandardStringCodec}. + * {@link Base16Codec} can be much faster (22x) than doing * uuid.toString().replaceAll("-", ""). + *

+ * Read: https://www.rfc-editor.org/rfc/rfc9562.html#name-uuid-format */ -public class StringCodec implements UuidCodec { +public class StandardStringCodec implements UuidCodec { /** * A shared immutable instance. */ - public static final StringCodec INSTANCE = new StringCodec(); + public static final StandardStringCodec INSTANCE = new StandardStringCodec(); private static final int DASH_POSITION_1 = 8; private static final int DASH_POSITION_2 = 13; diff --git a/src/main/java/com/github/f4b6a3/uuid/codec/UriCodec.java b/src/main/java/com/github/f4b6a3/uuid/codec/UriCodec.java index 0fa4e37f..f8928881 100644 --- a/src/main/java/com/github/f4b6a3/uuid/codec/UriCodec.java +++ b/src/main/java/com/github/f4b6a3/uuid/codec/UriCodec.java @@ -81,7 +81,7 @@ public UUID decode(URI uri) { if (!isUuidUri(uri)) { throw InvalidUuidException.newInstance(uri); } - return StringCodec.INSTANCE.decode(uri.toString()); + return StandardStringCodec.INSTANCE.decode(uri.toString()); } /** diff --git a/src/main/java/com/github/f4b6a3/uuid/codec/UrnCodec.java b/src/main/java/com/github/f4b6a3/uuid/codec/UrnCodec.java index 49a1b0bf..c281344a 100644 --- a/src/main/java/com/github/f4b6a3/uuid/codec/UrnCodec.java +++ b/src/main/java/com/github/f4b6a3/uuid/codec/UrnCodec.java @@ -66,7 +66,7 @@ public class UrnCodec implements UuidCodec { @Override public String encode(UUID uuid) { UuidValidator.validate(uuid); - return URN_PREFIX + StringCodec.INSTANCE.encode(uuid); + return URN_PREFIX + StandardStringCodec.INSTANCE.encode(uuid); } /** @@ -81,7 +81,7 @@ public UUID decode(String urn) { if (!isUuidUrn(urn)) { throw InvalidUuidException.newInstance(urn); } - return StringCodec.INSTANCE.decode(urn); + return StandardStringCodec.INSTANCE.decode(urn); } /** diff --git a/src/main/java/com/github/f4b6a3/uuid/codec/other/NcnameCodec.java b/src/main/java/com/github/f4b6a3/uuid/codec/other/NcnameCodec.java index 8126c256..96092966 100644 --- a/src/main/java/com/github/f4b6a3/uuid/codec/other/NcnameCodec.java +++ b/src/main/java/com/github/f4b6a3/uuid/codec/other/NcnameCodec.java @@ -27,7 +27,7 @@ import java.util.Arrays; import java.util.UUID; -import com.github.f4b6a3.uuid.codec.BinaryCodec; +import com.github.f4b6a3.uuid.codec.StandardBinaryCodec; import com.github.f4b6a3.uuid.codec.UuidCodec; import com.github.f4b6a3.uuid.codec.base.Base32Codec; import com.github.f4b6a3.uuid.codec.base.Base64UrlCodec; @@ -175,7 +175,7 @@ public String encode(UUID uuid) { UuidValidator.validate(uuid); int version = uuid.version(); - byte[] bytes = BinaryCodec.INSTANCE.encode(uuid); + byte[] bytes = StandardBinaryCodec.INSTANCE.encode(uuid); int[] ints = ByteUtil.toInts(bytes); int variant = (ints[2] & 0xf0000000) >>> 24; @@ -187,7 +187,7 @@ public String encode(UUID uuid) { bytes = ByteUtil.fromInts(ints); bytes[15] = (byte) ((bytes[15] & 0xff) >>> this.shift); - UUID uuuu = BinaryCodec.INSTANCE.decode(bytes); + UUID uuuu = StandardBinaryCodec.INSTANCE.decode(bytes); String encoded = this.codec.encode(uuuu).substring(0, this.length - 1); // if base is 64, use upper case version, else use lower case @@ -222,7 +222,7 @@ public UUID decode(String ncname) { String substring = ncname.substring(1, ncname.length()); UUID uuid = this.codec.decode(substring + padding); - byte[] bytes = BinaryCodec.INSTANCE.encode(uuid); + byte[] bytes = StandardBinaryCodec.INSTANCE.encode(uuid); bytes[15] = (byte) ((bytes[15] & 0xff) << this.shift); int[] ints = ByteUtil.toInts(bytes); @@ -237,6 +237,6 @@ public UUID decode(String ncname) { bytes = ByteUtil.fromInts(ints); - return BinaryCodec.INSTANCE.decode(bytes); + return StandardBinaryCodec.INSTANCE.decode(bytes); } } diff --git a/src/main/java/com/github/f4b6a3/uuid/factory/UuidFactory.java b/src/main/java/com/github/f4b6a3/uuid/factory/UuidFactory.java index dcf7a09c..eff1bfb4 100644 --- a/src/main/java/com/github/f4b6a3/uuid/factory/UuidFactory.java +++ b/src/main/java/com/github/f4b6a3/uuid/factory/UuidFactory.java @@ -29,8 +29,8 @@ import java.util.Objects; import java.util.UUID; -import com.github.f4b6a3.uuid.codec.BinaryCodec; -import com.github.f4b6a3.uuid.codec.StringCodec; +import com.github.f4b6a3.uuid.codec.StandardBinaryCodec; +import com.github.f4b6a3.uuid.codec.StandardStringCodec; import com.github.f4b6a3.uuid.enums.UuidLocalDomain; import com.github.f4b6a3.uuid.enums.UuidNamespace; import com.github.f4b6a3.uuid.enums.UuidVersion; @@ -354,7 +354,7 @@ protected static byte[] namespaceBytes(UuidNamespace namespace) { */ protected static byte[] namespaceBytes(UUID namespace) { if (namespace != null) { - return BinaryCodec.INSTANCE.encode(namespace); + return StandardBinaryCodec.INSTANCE.encode(namespace); } return null; // the name space can be null } @@ -368,7 +368,7 @@ protected static byte[] namespaceBytes(UUID namespace) { */ protected static byte[] namespaceBytes(String namespace) { if (namespace != null) { - return BinaryCodec.INSTANCE.encode(StringCodec.INSTANCE.decode(namespace)); + return StandardBinaryCodec.INSTANCE.encode(StandardStringCodec.INSTANCE.decode(namespace)); } return null; // the name space can be null } diff --git a/src/test/java/com/github/f4b6a3/uuid/codec/BinaryCodecTest.java b/src/test/java/com/github/f4b6a3/uuid/codec/BinaryCodecTest.java index da33b5eb..c4e4a175 100644 --- a/src/test/java/com/github/f4b6a3/uuid/codec/BinaryCodecTest.java +++ b/src/test/java/com/github/f4b6a3/uuid/codec/BinaryCodecTest.java @@ -16,7 +16,7 @@ public class BinaryCodecTest { @Test public void testEncode() { - BinaryCodec codec = new BinaryCodec(); + StandardBinaryCodec codec = new StandardBinaryCodec(); for (int i = 0; i < DEFAULT_LOOP_LIMIT; i++) { // UuidCreator.toBytes(); @@ -44,7 +44,7 @@ public void testEncode() { @Test public void testDecode() { - BinaryCodec codec = new BinaryCodec(); + StandardBinaryCodec codec = new StandardBinaryCodec(); for (int i = 0; i < DEFAULT_LOOP_LIMIT; i++) { // UuidCreator.fromBytes(); @@ -72,7 +72,7 @@ public void testDecode() { @Test public void testEncodeAndDecode() { - final BinaryCodec codec = new BinaryCodec(); + final StandardBinaryCodec codec = new StandardBinaryCodec(); for (int i = 0; i < DEFAULT_LOOP_LIMIT; i++) { UUID uuid = UUID.randomUUID(); @@ -84,7 +84,7 @@ public void testEncodeAndDecode() { @Test public void testEncodeInvalidUuidException() { - BinaryCodec codec = new BinaryCodec(); + StandardBinaryCodec codec = new StandardBinaryCodec(); { try { @@ -118,7 +118,7 @@ public void testEncodeInvalidUuidException() { @Test public void testDecodeInvalidUuidException() { - BinaryCodec codec = new BinaryCodec(); + StandardBinaryCodec codec = new StandardBinaryCodec(); { try { diff --git a/src/test/java/com/github/f4b6a3/uuid/codec/StringCodecTest.java b/src/test/java/com/github/f4b6a3/uuid/codec/StringCodecTest.java index fbcca884..0b4b13a0 100644 --- a/src/test/java/com/github/f4b6a3/uuid/codec/StringCodecTest.java +++ b/src/test/java/com/github/f4b6a3/uuid/codec/StringCodecTest.java @@ -21,7 +21,7 @@ public class StringCodecTest { @Test public void testEncode() { - StringCodec codec = new StringCodec(); + StandardStringCodec codec = new StandardStringCodec(); for (int i = 0; i < DEFAULT_LOOP_LIMIT; i++) { // UuidCreator.toString(); @@ -45,7 +45,7 @@ public void testEncode() { @Test public void testDecode() { - StringCodec codec = new StringCodec(); + StandardStringCodec codec = new StandardStringCodec(); for (int i = 0; i < DEFAULT_LOOP_LIMIT; i++) { // UuidCreator.fromString(); @@ -100,7 +100,7 @@ public void testDecode() { @Test public void testEncodeAndDecode() { - final StringCodec codec = new StringCodec(); + final StandardStringCodec codec = new StandardStringCodec(); for (int i = 0; i < DEFAULT_LOOP_LIMIT; i++) { UUID uuid = UUID.randomUUID(); @@ -112,7 +112,7 @@ public void testEncodeAndDecode() { @Test public void testEncodeInvalidUuidException() { - StringCodec codec = new StringCodec(); + StandardStringCodec codec = new StandardStringCodec(); { try { @@ -146,7 +146,7 @@ public void testEncodeInvalidUuidException() { @Test public void testDecodeInvalidUuidException() { - StringCodec codec = new StringCodec(); + StandardStringCodec codec = new StandardStringCodec(); try { String string = new UUID(0L, 0L).toString(); @@ -232,19 +232,19 @@ public void testModifyString() { { // 00000000-0000-0000-0000-000000000000 String string = UUID.randomUUID().toString(); - assertEquals(string, StringCodec.modify(string)); + assertEquals(string, StandardStringCodec.modify(string)); } { // urn:uuid:00000000-0000-0000-0000-000000000000 String string = UUID.randomUUID().toString(); - assertEquals(string, StringCodec.modify(URN_PREFIX + string)); + assertEquals(string, StandardStringCodec.modify(URN_PREFIX + string)); } { // {00000000-0000-0000-0000-000000000000} String string = UUID.randomUUID().toString(); - assertEquals(string, StringCodec.modify("{" + string + "}")); + assertEquals(string, StandardStringCodec.modify("{" + string + "}")); } } diff --git a/src/test/java/com/github/f4b6a3/uuid/codec/base/BaseNCodec1Test.java b/src/test/java/com/github/f4b6a3/uuid/codec/base/BaseNCodec1Test.java index 1c901154..4729970d 100644 --- a/src/test/java/com/github/f4b6a3/uuid/codec/base/BaseNCodec1Test.java +++ b/src/test/java/com/github/f4b6a3/uuid/codec/base/BaseNCodec1Test.java @@ -3,7 +3,7 @@ import static org.junit.Assert.*; import org.junit.Test; -import com.github.f4b6a3.uuid.codec.BinaryCodec; +import com.github.f4b6a3.uuid.codec.StandardBinaryCodec; import com.github.f4b6a3.uuid.codec.UuidCodec; import com.github.f4b6a3.uuid.exception.InvalidUuidException; @@ -16,7 +16,7 @@ public class BaseNCodec1Test { private static final int DEFAULT_LOOP_LIMIT = 100; - private static final UuidCodec CODEC_BYTES = new BinaryCodec(); + private static final UuidCodec CODEC_BYTES = new StandardBinaryCodec(); // Alphabet used by BigInteger.toString(32); protected static final char[] ALPHABET_JAVA = "0123456789abcdefghijklmnopqrstuv".toCharArray(); diff --git a/src/test/java/com/github/f4b6a3/uuid/codec/base/function/BaseNRemainderDecoderTest.java b/src/test/java/com/github/f4b6a3/uuid/codec/base/function/BaseNRemainderDecoderTest.java index 621f18c7..ef3001e1 100644 --- a/src/test/java/com/github/f4b6a3/uuid/codec/base/function/BaseNRemainderDecoderTest.java +++ b/src/test/java/com/github/f4b6a3/uuid/codec/base/function/BaseNRemainderDecoderTest.java @@ -10,7 +10,7 @@ import org.junit.Test; -import com.github.f4b6a3.uuid.codec.BinaryCodec; +import com.github.f4b6a3.uuid.codec.StandardBinaryCodec; import com.github.f4b6a3.uuid.codec.base.Base62Codec; import com.github.f4b6a3.uuid.codec.base.BaseN; @@ -23,7 +23,7 @@ public void testDecode() { for (int i = 0; i < 1000; i++) { String string = getRandomString(Base62Codec.INSTANCE.getBase()); UUID uuid = Base62Codec.INSTANCE.decode(string); - byte[] bytes = BinaryCodec.INSTANCE.encode(uuid); + byte[] bytes = StandardBinaryCodec.INSTANCE.encode(uuid); assertEquals(Arrays.toString(decode(Base62Codec.INSTANCE.getBase(), string)), Arrays.toString(bytes)); } } @@ -68,13 +68,13 @@ public void testMultiply() { } protected static long[] toLongs(byte[] bytes) { - UUID uuid = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid = StandardBinaryCodec.INSTANCE.decode(bytes); return new long[] { uuid.getMostSignificantBits(), uuid.getLeastSignificantBits() }; } protected static byte[] fromLongs(long[] longs) { UUID uuid = new UUID(longs[0], longs[1]); - return BinaryCodec.INSTANCE.encode(uuid); + return StandardBinaryCodec.INSTANCE.encode(uuid); } private String getRandomString(BaseN base) { diff --git a/src/test/java/com/github/f4b6a3/uuid/codec/base/function/BaseNRemainderEncoderTest.java b/src/test/java/com/github/f4b6a3/uuid/codec/base/function/BaseNRemainderEncoderTest.java index 1a1d6538..4a59a152 100644 --- a/src/test/java/com/github/f4b6a3/uuid/codec/base/function/BaseNRemainderEncoderTest.java +++ b/src/test/java/com/github/f4b6a3/uuid/codec/base/function/BaseNRemainderEncoderTest.java @@ -9,7 +9,7 @@ import org.junit.Test; -import com.github.f4b6a3.uuid.codec.BinaryCodec; +import com.github.f4b6a3.uuid.codec.StandardBinaryCodec; import com.github.f4b6a3.uuid.codec.base.Base62Codec; import com.github.f4b6a3.uuid.codec.base.BaseN; import com.github.f4b6a3.uuid.codec.base.BaseNCodec.CustomDivider; @@ -27,7 +27,7 @@ public void testEncode() { for (int i = 0; i < 1000; i++) { byte[] bytes = new byte[UUID_BYTES]; (new Random(seeder.nextLong())).nextBytes(bytes); - UUID uuid = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid = StandardBinaryCodec.INSTANCE.decode(bytes); String string = Base62Codec.INSTANCE.encode(uuid); assertEquals(encode(Base62Codec.INSTANCE.getBase(), bytes), string); } diff --git a/src/test/java/com/github/f4b6a3/uuid/codec/other/SlugCodecTest.java b/src/test/java/com/github/f4b6a3/uuid/codec/other/SlugCodecTest.java index fab4301a..9edcff1c 100644 --- a/src/test/java/com/github/f4b6a3/uuid/codec/other/SlugCodecTest.java +++ b/src/test/java/com/github/f4b6a3/uuid/codec/other/SlugCodecTest.java @@ -4,7 +4,7 @@ import org.junit.Test; -import com.github.f4b6a3.uuid.codec.BinaryCodec; +import com.github.f4b6a3.uuid.codec.StandardBinaryCodec; import com.github.f4b6a3.uuid.codec.UuidCodec; import com.github.f4b6a3.uuid.exception.InvalidUuidException; @@ -16,7 +16,7 @@ public class SlugCodecTest { private static final int DEFAULT_LOOP_LIMIT = 100; - private static final UuidCodec CODEC_BYTES = new BinaryCodec(); + private static final UuidCodec CODEC_BYTES = new StandardBinaryCodec(); @Test public void testEncode() { diff --git a/src/test/java/com/github/f4b6a3/uuid/factory/UuidFactoryTest.java b/src/test/java/com/github/f4b6a3/uuid/factory/UuidFactoryTest.java index f3b2bb43..3c0c4134 100644 --- a/src/test/java/com/github/f4b6a3/uuid/factory/UuidFactoryTest.java +++ b/src/test/java/com/github/f4b6a3/uuid/factory/UuidFactoryTest.java @@ -1,7 +1,7 @@ package com.github.f4b6a3.uuid.factory; import com.github.f4b6a3.uuid.UuidCreator; -import com.github.f4b6a3.uuid.codec.BinaryCodec; +import com.github.f4b6a3.uuid.codec.StandardBinaryCodec; import com.github.f4b6a3.uuid.codec.UuidCodec; import com.github.f4b6a3.uuid.factory.function.NodeIdFunction; import com.github.f4b6a3.uuid.util.UuidUtil; @@ -19,7 +19,7 @@ public abstract class UuidFactoryTest { protected static final String DUPLICATE_UUID_MSG = "A duplicate UUID was created"; - private static final UuidCodec bytesCodec = new BinaryCodec(); + private static final UuidCodec bytesCodec = new StandardBinaryCodec(); protected static final int THREAD_TOTAL = availableProcessors(); diff --git a/src/test/java/com/github/f4b6a3/uuid/util/UuidComparatorTest.java b/src/test/java/com/github/f4b6a3/uuid/util/UuidComparatorTest.java index ce956ee3..91f11acd 100644 --- a/src/test/java/com/github/f4b6a3/uuid/util/UuidComparatorTest.java +++ b/src/test/java/com/github/f4b6a3/uuid/util/UuidComparatorTest.java @@ -9,7 +9,7 @@ import org.junit.Test; -import com.github.f4b6a3.uuid.codec.BinaryCodec; +import com.github.f4b6a3.uuid.codec.StandardBinaryCodec; import com.github.f4b6a3.uuid.codec.other.TimeOrderedCodec; public class UuidComparatorTest { @@ -80,13 +80,13 @@ public void testCompareDefault() { for (int i = 0; i < DEFAULT_LOOP_MAX; i++) { bytes = ByteBuffer.allocate(16).putLong(random.nextLong()).putLong(random.nextLong()).array(); bytes = setVersion(bytes, 1); // set version 1 - UUID uuid1 = BinaryCodec.INSTANCE.decode(rearrange(bytes)); + UUID uuid1 = StandardBinaryCodec.INSTANCE.decode(rearrange(bytes)); BigInteger number1 = new BigInteger(1, bytes); bytes = ByteBuffer.allocate(16).putLong(random.nextLong()).putLong(random.nextLong()).array(); bytes = setVersion(bytes, 1); // set version 1 - UUID uuid2 = BinaryCodec.INSTANCE.decode(rearrange(bytes)); - UUID uuid3 = BinaryCodec.INSTANCE.decode(rearrange(bytes)); + UUID uuid2 = StandardBinaryCodec.INSTANCE.decode(rearrange(bytes)); + UUID uuid3 = StandardBinaryCodec.INSTANCE.decode(rearrange(bytes)); BigInteger number2 = new BigInteger(1, bytes); BigInteger number3 = new BigInteger(1, bytes); @@ -107,13 +107,13 @@ public void testCompareDefault() { for (int i = 0; i < DEFAULT_LOOP_MAX; i++) { bytes = ByteBuffer.allocate(16).putLong(zero).putLong(random.nextLong()).array(); bytes = setVersion(bytes, 1); // set version 1 - UUID uuid1 = BinaryCodec.INSTANCE.decode(rearrange(bytes)); + UUID uuid1 = StandardBinaryCodec.INSTANCE.decode(rearrange(bytes)); BigInteger number1 = new BigInteger(1, bytes); bytes = ByteBuffer.allocate(16).putLong(zero).putLong(random.nextLong()).array(); bytes = setVersion(bytes, 1); // set version 1 - UUID uuid2 = BinaryCodec.INSTANCE.decode(rearrange(bytes)); - UUID uuid3 = BinaryCodec.INSTANCE.decode(rearrange(bytes)); + UUID uuid2 = StandardBinaryCodec.INSTANCE.decode(rearrange(bytes)); + UUID uuid3 = StandardBinaryCodec.INSTANCE.decode(rearrange(bytes)); BigInteger number2 = new BigInteger(1, bytes); BigInteger number3 = new BigInteger(1, bytes); @@ -134,13 +134,13 @@ public void testCompareDefault() { for (int i = 0; i < DEFAULT_LOOP_MAX; i++) { bytes = ByteBuffer.allocate(16).putLong(random.nextLong()).putLong(zero).array(); bytes = setVersion(bytes, 1); // set version 1 - UUID uuid1 = BinaryCodec.INSTANCE.decode(rearrange(bytes)); + UUID uuid1 = StandardBinaryCodec.INSTANCE.decode(rearrange(bytes)); BigInteger number1 = new BigInteger(1, bytes); bytes = ByteBuffer.allocate(16).putLong(random.nextLong()).putLong(zero).array(); bytes = setVersion(bytes, 1); // set version 1 - UUID uuid2 = BinaryCodec.INSTANCE.decode(rearrange(bytes)); - UUID uuid3 = BinaryCodec.INSTANCE.decode(rearrange(bytes)); + UUID uuid2 = StandardBinaryCodec.INSTANCE.decode(rearrange(bytes)); + UUID uuid3 = StandardBinaryCodec.INSTANCE.decode(rearrange(bytes)); BigInteger number2 = new BigInteger(1, bytes); BigInteger number3 = new BigInteger(1, bytes); @@ -168,12 +168,12 @@ public void testCompareOpaque() { for (int i = 0; i < DEFAULT_LOOP_MAX; i++) { bytes = ByteBuffer.allocate(16).putLong(random.nextLong()).putLong(random.nextLong()).array(); - UUID uuid1 = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid1 = StandardBinaryCodec.INSTANCE.decode(bytes); BigInteger number1 = new BigInteger(1, bytes); bytes = ByteBuffer.allocate(16).putLong(random.nextLong()).putLong(random.nextLong()).array(); - UUID uuid2 = BinaryCodec.INSTANCE.decode(bytes); - UUID uuid3 = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid2 = StandardBinaryCodec.INSTANCE.decode(bytes); + UUID uuid3 = StandardBinaryCodec.INSTANCE.decode(bytes); BigInteger number2 = new BigInteger(1, bytes); BigInteger number3 = new BigInteger(1, bytes); @@ -190,12 +190,12 @@ public void testCompareOpaque() { for (int i = 0; i < DEFAULT_LOOP_MAX; i++) { bytes = ByteBuffer.allocate(16).putLong(zero).putLong(random.nextLong()).array(); - UUID uuid1 = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid1 = StandardBinaryCodec.INSTANCE.decode(bytes); BigInteger number1 = new BigInteger(1, bytes); bytes = ByteBuffer.allocate(16).putLong(zero).putLong(random.nextLong()).array(); - UUID uuid2 = BinaryCodec.INSTANCE.decode(bytes); - UUID uuid3 = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid2 = StandardBinaryCodec.INSTANCE.decode(bytes); + UUID uuid3 = StandardBinaryCodec.INSTANCE.decode(bytes); BigInteger number2 = new BigInteger(1, bytes); BigInteger number3 = new BigInteger(1, bytes); @@ -212,12 +212,12 @@ public void testCompareOpaque() { for (int i = 0; i < DEFAULT_LOOP_MAX; i++) { bytes = ByteBuffer.allocate(16).putLong(random.nextLong()).putLong(zero).array(); - UUID uuid1 = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid1 = StandardBinaryCodec.INSTANCE.decode(bytes); BigInteger number1 = new BigInteger(1, bytes); bytes = ByteBuffer.allocate(16).putLong(random.nextLong()).putLong(zero).array(); - UUID uuid2 = BinaryCodec.INSTANCE.decode(bytes); - UUID uuid3 = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid2 = StandardBinaryCodec.INSTANCE.decode(bytes); + UUID uuid3 = StandardBinaryCodec.INSTANCE.decode(bytes); BigInteger number2 = new BigInteger(1, bytes); BigInteger number3 = new BigInteger(1, bytes); @@ -234,16 +234,16 @@ public void testCompareOpaque() { } private byte[] setVersion(byte[] bytes, int version) { - UUID uuid = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid = StandardBinaryCodec.INSTANCE.decode(bytes); uuid = UuidUtil.setVersion(uuid, version); - return BinaryCodec.INSTANCE.encode(uuid); + return StandardBinaryCodec.INSTANCE.encode(uuid); } private byte[] rearrange(byte[] bytes) { - UUID uuid = BinaryCodec.INSTANCE.decode(bytes); + UUID uuid = StandardBinaryCodec.INSTANCE.decode(bytes); uuid = UuidUtil.setVersion(uuid, 6); uuid = TimeOrderedCodec.INSTANCE.decode(uuid); uuid = UuidUtil.setVersion(uuid, 1); - return BinaryCodec.INSTANCE.encode(uuid); + return StandardBinaryCodec.INSTANCE.encode(uuid); } }