001/* 002 * SPDX-License-Identifier: Apache-2.0 003 * 004 * Copyright 2025-2026 The Enola <https://enola.dev> Authors 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * https://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package dev.enola.data.id; 019 020import com.google.errorprone.annotations.Immutable; 021 022import dev.enola.common.convert.ObjectToStringBiConverters; 023import dev.enola.data.iri.IRIConverter; 024 025import java.util.UUID; 026 027@Immutable 028public final class UUID_IRI extends IDIRI<UUID> { 029 // TODO /* non-public! */ 030 031 static final ConverterX<UUID_IRI, UUID> CONVERTER = 032 new ConverterX<>("urn:uuid:", ObjectToStringBiConverters.UUID) { 033 @Override 034 protected UUID_IRI create(UUID id) { 035 return new UUID_IRI(id); 036 } 037 }; 038 039 // TODO Remove public 040 public UUID_IRI(UUID uuid) { 041 super(uuid); 042 } 043 044 public UUID_IRI() { 045 // See also dev.enola.common.ByteSeq#random() 046 super(UUID.randomUUID()); 047 } 048 049 @Override 050 @SuppressWarnings("unchecked") 051 protected IRIConverter<UUID_IRI> iriConverter() { 052 return CONVERTER; 053 } 054 055 @Override 056 protected boolean isComparableTo(Object other) { 057 return other instanceof UUID_IRI; 058 } 059}