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.impl.ImmutableThing; 022import dev.enola.thing.java.ProxyTBF; 023import dev.enola.thing.java.TBF; 024 025public interface Property extends Type { 026 027 String CLASS_IRI = "https://enola.dev/meta/Property"; 028 029 default Property parent() { 030 return getThing(KIRI.E.PARENT, Property.class).get(); 031 } 032 033 default Datatype datatype() { 034 return getThing(KIRI.E.META.DATATYPE, Datatype.class).get(); 035 } 036 037 /* 038 default Multiplicity multiplicity() { 039 return Multiplicity.valueOf(getString(KIRI.E.META.MULTIPLICITY)); 040 } 041 042 enum Multiplicity { 043 Single, 044 045 / ** Multiple, unordered * / 046 Set, 047 048 // TODO List, for Multiple, ordered? 049 } 050 */ 051 interface Builder<B extends Property> extends Property, Type.Builder<B> { // skipcq: JAVA-E0169 052 053 @Override 054 default Property.Builder<B> schema(Schema schema) { 055 Type.Builder.super.schema(schema); 056 return this; 057 } 058 059 @Override 060 default Property.Builder<B> name(String name) { 061 Type.Builder.super.name(name); 062 return this; 063 } 064 065 default Property.Builder<B> parent(Property parent) { 066 set(KIRI.E.PARENT, parent); 067 return this; 068 } 069 070 default Property.Builder<B> datatype(Datatype datatype) { 071 set(KIRI.E.META.DATATYPE, datatype); 072 return this; 073 } 074 075 // TODO Property.Builder<B> multiplicity(Multiplicity multiplicity); 076 } 077 078 @SuppressWarnings("unchecked") 079 static Property.Builder<Property> builder(TBF tbf) { 080 return tbf.create(Property.Builder.class, Property.class); 081 } 082 083 @SuppressWarnings("unchecked") 084 static Property.Builder<Property> builder() { 085 return builder(new ProxyTBF(ImmutableThing.FACTORY)); 086 } 087}