Skip to content

Package: InvalidValueMappingException

InvalidValueMappingException

nameinstructionbranchcomplexitylinemethod
InvalidValueMappingException(String, Object, Class)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
InvalidValueMappingException(Throwable, String, Object, Class)
M: 33 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getName()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getType()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getValue()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2020, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.storable.exception;
14:
15: /**
16: * {@link MappingException} to {@code throw} when the value given to be serialized cannot be mapped to any type.
17: *
18: * @since 1.3.0
19: */
20: public class InvalidValueMappingException extends MappingException {
21:
22: private final String name;
23: private final Object value;
24: private final Class<?> type;
25:
26: /**
27: * Constructor.
28: *
29: * @param value The value for which mapping is not supported by the code.
30: * @since 1.3.0
31: */
32: public InvalidValueMappingException(String name, Object value, Class<?> type) {
33: this(null, name, value, type);
34: }
35:
36: /**
37: * Constructor.
38: *
39: * @param cause The root {@link Throwable} of this {@link InvalidValueMappingException}.
40: * @param value The value for which mapping is not supported by the code.
41: * @since 1.3.0
42: */
43: public InvalidValueMappingException(Throwable cause, String name, Object value, Class<?> type) {
44: super(StorableErrorCodes.INVALID_VALUE, cause, name, value, type);
45:
46: this.name = name;
47: this.value = value;
48:• this.type = value != null ? value.getClass() : null;
49: }
50:
51: /**
52: * Gets the name of the mappable value.
53: *
54: * @return The name of the mappable value.
55: * @since 1.3.0
56: */
57: public String getName() {
58: return name;
59: }
60:
61: /**
62: * Gets the not valid value according to {@link #getType()}.
63: *
64: * @return The not valid value.
65: * @since 1.3.0
66: */
67: public Object getValue() {
68: return value;
69: }
70:
71: /**
72: * Gets the not valid {@link Class} according to {@link #getValue()}.
73: *
74: * @return The not valid {@link Class} according to {@link #getValue()}.
75: * @since 1.3.0
76: */
77: public Class<?> getType() {
78: return type;
79: }
80: }