Skip to content

Package: ListDescriptorFactory

ListDescriptorFactory

nameinstructionbranchcomplexitylinemethod
ListDescriptorFactory()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
createReferencedListDescriptor(NamedResource, ListAttribute)
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
createReferencedListValueDescriptor(NamedResource, ListAttribute)
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
createSimpleListDescriptor(NamedResource, ListAttribute)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
createSimpleListValueDescriptor(NamedResource, ListAttribute)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
nodeContentProperty(ListAttribute)
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2024 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.oom;
19:
20: import cz.cvut.kbss.jopa.model.metamodel.Attribute;
21: import cz.cvut.kbss.jopa.model.metamodel.ListAttribute;
22: import cz.cvut.kbss.ontodriver.descriptor.ReferencedListDescriptor;
23: import cz.cvut.kbss.ontodriver.descriptor.ReferencedListDescriptorImpl;
24: import cz.cvut.kbss.ontodriver.descriptor.ReferencedListValueDescriptor;
25: import cz.cvut.kbss.ontodriver.descriptor.SimpleListDescriptor;
26: import cz.cvut.kbss.ontodriver.descriptor.SimpleListDescriptorImpl;
27: import cz.cvut.kbss.ontodriver.descriptor.SimpleListValueDescriptor;
28: import cz.cvut.kbss.ontodriver.model.Assertion;
29: import cz.cvut.kbss.ontodriver.model.NamedResource;
30:
31: /**
32: * Creates descriptors for list attributes.
33: */
34: class ListDescriptorFactory {
35:
36: private ListDescriptorFactory() {
37: throw new AssertionError();
38: }
39:
40: static SimpleListDescriptor createSimpleListDescriptor(NamedResource owner, ListAttribute<?, ?> attribute) {
41: final boolean inferred = attribute.isInferred();
42: final Assertion listProperty = Assertion.createObjectPropertyAssertion(attribute.getIRI().toURI(), inferred);
43: final Assertion nextNodeProperty = Assertion.createObjectPropertyAssertion(attribute.getHasNextPropertyIRI()
44: .toURI(), inferred);
45: return new SimpleListDescriptorImpl(owner, listProperty, nextNodeProperty);
46: }
47:
48: static SimpleListValueDescriptor createSimpleListValueDescriptor(NamedResource owner,
49: ListAttribute<?, ?> attribute) {
50: final boolean inferred = attribute.isInferred();
51: final Assertion listProperty = Assertion.createObjectPropertyAssertion(attribute.getIRI().toURI(), inferred);
52: final Assertion nextNodeProperty = Assertion.createObjectPropertyAssertion(attribute.getHasNextPropertyIRI()
53: .toURI(), inferred);
54: return new SimpleListValueDescriptor(owner, listProperty, nextNodeProperty);
55: }
56:
57: static ReferencedListDescriptor createReferencedListDescriptor(NamedResource owner, ListAttribute<?, ?> attribute) {
58: final boolean inferred = attribute.isInferred();
59: final Assertion listProperty = Assertion.createObjectPropertyAssertion(attribute.getIRI().toURI(), inferred);
60: final Assertion nextNodeProperty = Assertion
61: .createObjectPropertyAssertion(attribute.getHasNextPropertyIRI().toURI(), inferred);
62: final Assertion nodeContentProperty = nodeContentProperty(attribute);
63: return new ReferencedListDescriptorImpl(owner, listProperty, nextNodeProperty, nodeContentProperty, attribute.isRDFCollection());
64: }
65:
66: private static Assertion nodeContentProperty(ListAttribute<?, ?> attribute) {
67:• return attribute.getPersistentAttributeType() == Attribute.PersistentAttributeType.OBJECT
68: ? Assertion.createObjectPropertyAssertion(attribute.getHasContentsPropertyIRI()
69: .toURI(), attribute.isInferred())
70: : Assertion.createDataPropertyAssertion(attribute.getHasContentsPropertyIRI()
71: .toURI(), attribute.isInferred());
72: }
73:
74: static <V> ReferencedListValueDescriptor<V> createReferencedListValueDescriptor(NamedResource owner,
75: ListAttribute<?, ?> attribute) {
76: final boolean inferred = attribute.isInferred();
77: final Assertion listProperty = Assertion.createObjectPropertyAssertion(attribute.getIRI().toURI(), inferred);
78: final Assertion nextNodeProperty = Assertion
79: .createObjectPropertyAssertion(attribute.getHasNextPropertyIRI().toURI(), inferred);
80: final Assertion nodeContentProperty = nodeContentProperty(attribute);
81: return new ReferencedListValueDescriptor<>(owner, listProperty, nextNodeProperty, nodeContentProperty, attribute.isRDFCollection());
82: }
83: }