001/* 002 * SPDX-License-Identifier: Apache-2.0 003 * 004 * Copyright 2024-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.model.enola.meta; 019 020import dev.enola.thing.KIRI; 021import dev.enola.thing.Thing; 022import dev.enola.thing.java.TBF; 023 024import org.jspecify.annotations.Nullable; 025 026// skipcq: JAVA-E0169 027public interface Class extends Type, dev.enola.model.w3.rdfs.Class { 028 029 String CLASS_IRI = "https://enola.dev/meta/Class"; 030 031 default Iterable<Class> parents() { 032 return getThings(KIRI.E.META.PARENTS, Class.class); 033 } 034 035 // NB: Cannot be named properties() due to conflict with Thing#properties() 036 default Iterable<Property> classProperties() { 037 return getThings(KIRI.E.META.CLASS_PROPERTIES, Property.class); 038 } 039 040 default Iterable<Property> classIdProperties() { 041 return getThings(KIRI.E.META.CLASS_ID_PROPERTIES, Property.class); 042 } 043 044 default @Nullable String iriTemplate() { 045 return getString(KIRI.E.META.IRI_TEMPLATE); 046 } 047 048 interface Builder<B extends Class> // skipcq: JAVA-E0169 049 extends Thing.Builder<B>, 050 Class, 051 Type.Builder<B>, 052 dev.enola.model.w3.rdfs.Class.Builder<B> { // skipcq: JAVA-E0169 053 054 @Override 055 default Class.Builder<B> schema(Schema schema) { 056 Type.Builder.super.schema(schema); 057 return this; 058 } 059 060 @Override 061 default Class.Builder<B> name(String name) { 062 Type.Builder.super.name(name); 063 return this; 064 } 065 066 default Class.Builder<B> addParent(Class parent) { 067 add(KIRI.E.META.PARENTS, parent.iri()); 068 return this; 069 } 070 071 default Class.Builder<B> addClassProperty(Property property) { 072 add(KIRI.E.META.CLASS_PROPERTIES, property.iri()); 073 return this; 074 } 075 076 default Class.Builder<B> addClassIdProperty(Property property) { 077 add(KIRI.E.META.CLASS_ID_PROPERTIES, property.iri()); 078 return this; 079 } 080 081 default Class.Builder<B> iriTemplate(String iriTemplate) { 082 set(KIRI.E.META.IRI_TEMPLATE, iriTemplate); 083 return this; 084 } 085 } 086 087 @SuppressWarnings("unchecked") 088 static Class.Builder<Class> builder(TBF tbf) { 089 return tbf.create(Class.Builder.class, Class.class); 090 } 091}