Skip to contentMethod: ensureDataProperty(OWLDataPropertyExpression)
1: /*
2: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.owl2java;
19:
20: import cz.cvut.kbss.jopa.owl2java.exception.UnsupportedICException;
21: import org.semanticweb.owlapi.model.*;
22:
23: public class Utils {
24:
25: private Utils() {
26: throw new AssertionError();
27: }
28:
29: static OWLDatatype ensureDatatype(final OWLDataRange r) {
30: if (!r.isOWLDatatype()) {
31: throw new UnsupportedICException("Data ranges not supported: " + r);
32: }
33:
34: if (!r.asOWLDatatype().isBuiltIn()) {
35: throw new UnsupportedICException("Only built in datatypes are supported: " + r);
36: }
37: return r.asOWLDatatype();
38: }
39:
40: static OWLClass ensureClass(final OWLClassExpression r) {
41: if (!r.isAnonymous()) {
42: return r.asOWLClass();
43: }
44: throw new UnsupportedICException("Only named classes are supported: " + r);
45: }
46:
47: static OWLDataProperty ensureDataProperty(final OWLDataPropertyExpression e) {
48:• if (e.isAnonymous()) {
49: throw new UnsupportedICException("Data property expressions not supported: " + e);
50: }
51: return e.asOWLDataProperty();
52: }
53:
54: static OWLObjectProperty ensureObjectProperty(final OWLObjectPropertyExpression e) {
55: if (e.isAnonymous()) {
56: throw new UnsupportedICException("Object property expressions not supported: " + e);
57: }
58: return e.asOWLObjectProperty();
59: }
60: }