Skip to content

Package: MetamodelUtils

MetamodelUtils

nameinstructionbranchcomplexitylinemethod
MetamodelUtils()
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%
checkForModuleSignatureExtension(Collection, Metamodel)
M: 0 C: 33
100%
M: 1 C: 7
88%
M: 1 C: 4
80%
M: 0 C: 10
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.utils;
16:
17: import cz.cvut.kbss.jopa.model.metamodel.Metamodel;
18:
19: import java.net.URI;
20: import java.util.Collection;
21: import java.util.Objects;
22: import java.util.Set;
23:
24: /**
25: * Metamodel-related utility functions.
26: */
27: public class MetamodelUtils {
28:
29: private MetamodelUtils() {
30: throw new AssertionError();
31: }
32:
33: /**
34: * Checks whether the specified set of types contains any types not contained in the current module extraction
35: * signature and if so, it adds them into the signature.
36: *
37: * @param types The types to check (can be {@code null})
38: * @param metamodel Persistence unit metamodel containing module extraction signature
39: */
40: public static void checkForModuleSignatureExtension(Collection<?> types, Metamodel metamodel) {
41: Objects.requireNonNull(metamodel);
42:• if (types == null || types.isEmpty()) {
43: return;
44: }
45: final Set<URI> signature = metamodel.getModuleExtractionExtraSignature();
46:• for (Object elem : types) {
47: final URI u = EntityPropertiesUtils.getValueAsURI(elem);
48:• if (!signature.contains(u)) {
49: metamodel.addUriToModuleExtractionSignature(u);
50: }
51: }
52: }
53: }