Skip to content

Package: MetamodelInitializationException

MetamodelInitializationException

nameinstructionbranchcomplexitylinemethod
MetamodelInitializationException(String)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
MetamodelInitializationException(String, Throwable)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
MetamodelInitializationException(Throwable)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
incorrectEntityListenerCallbackSignatureMessage(Class, Method)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
incorrectLifecycleListenerSignatureMessage(Class, Method)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
invalidArgumentsForEntityListenerCallback(Class, Method)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
invalidArgumentsForLifecycleListener(Class, Method)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
invalidEntityListenerCallbackModifier(Class, Method)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
invalidEntityListenerCallbackParameterType(Class, Class, Method)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
invalidLifecycleListenerModifier(Class, Method)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
invalidReturnTypeForEntityListenerCallback(Class, Method)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
invalidReturnTypeForLifecycleListener(Class, Method)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
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.exception;
19:
20: import cz.cvut.kbss.jopa.exceptions.OWLPersistenceException;
21:
22: import java.lang.reflect.Method;
23:
24: /**
25: * Indicates an error when building application persistence metamodel.
26: */
27: public class MetamodelInitializationException extends OWLPersistenceException {
28:
29: private static final String VOID_RETURN_TYPE_MSG = " Its return type should be void.";
30: private static final String INVALID_MODIFIER_MSG = " It should not be static or final.";
31:
32: public MetamodelInitializationException(String message, Throwable cause) {
33: super(message, cause);
34: }
35:
36: public MetamodelInitializationException(String message) {
37: super(message);
38: }
39:
40: public MetamodelInitializationException(Throwable cause) {
41: super(cause);
42: }
43:
44: public static MetamodelInitializationException invalidArgumentsForLifecycleListener(Class<?> type,
45: Method listener) {
46: return new MetamodelInitializationException(
47: incorrectLifecycleListenerSignatureMessage(type, listener) + " It should not have any arguments.");
48: }
49:
50: private static String incorrectLifecycleListenerSignatureMessage(Class<?> type, Method listener) {
51: return "The callback method [" + listener.getName() + "] in type [" + type.getName() +
52: "] has incorrect signature.";
53: }
54:
55: public static MetamodelInitializationException invalidReturnTypeForLifecycleListener(Class<?> type,
56: Method listener) {
57: return new MetamodelInitializationException(
58: incorrectLifecycleListenerSignatureMessage(type, listener) + VOID_RETURN_TYPE_MSG);
59: }
60:
61: public static MetamodelInitializationException invalidLifecycleListenerModifier(Class<?> type, Method listener) {
62: return new MetamodelInitializationException(
63: incorrectLifecycleListenerSignatureMessage(type, listener) + INVALID_MODIFIER_MSG);
64: }
65:
66: public static MetamodelInitializationException invalidArgumentsForEntityListenerCallback(Class<?> type,
67: Method callback) {
68: return new MetamodelInitializationException(incorrectEntityListenerCallbackSignatureMessage(type, callback) +
69: " It should take exactly one argument.");
70: }
71:
72: private static String incorrectEntityListenerCallbackSignatureMessage(Class<?> type, Method callback) {
73: return "The callback method [" + callback.getName() + "] in entity listener [" + type.getName() +
74: "] has incorrect signature.";
75: }
76:
77: public static MetamodelInitializationException invalidReturnTypeForEntityListenerCallback(Class<?> type,
78: Method callback) {
79: return new MetamodelInitializationException(
80: incorrectEntityListenerCallbackSignatureMessage(type, callback) + VOID_RETURN_TYPE_MSG);
81: }
82:
83: public static MetamodelInitializationException invalidEntityListenerCallbackModifier(Class<?> type,
84: Method callback) {
85: return new MetamodelInitializationException(
86: incorrectEntityListenerCallbackSignatureMessage(type, callback) + INVALID_MODIFIER_MSG);
87: }
88:
89: public static MetamodelInitializationException invalidEntityListenerCallbackParameterType(Class<?> managedType,
90: Class<?> type,
91: Method callback) {
92: return new MetamodelInitializationException(
93: incorrectEntityListenerCallbackSignatureMessage(type, callback) + " Its parameter should be of type [" +
94: Object.class.getName() + "] or [" + managedType.getName() + "].");
95: }
96: }