Improve RpcRoutingStrategyTest
[mdsal.git] / binding / mdsal-binding-generator-impl / src / main / java / org / opendaylight / mdsal / binding / generator / impl / RenameMappingException.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.generator.impl;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
14 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
15
16 /**
17  * Exception thrown from ModuleContext when it detects a Java namespace clash between generated classes. This can occur
18  * because we are mapping multiple YANG namespaces to a single Java class namespace.
19  *
20  * <p>
21  * While handling this case via an exception (and related mechanics) is a bit slow, it works with minimal disturbance
22  * of existing logic. The situation should not be very common and hence it should provide an acceptable performance
23  * envelope.
24  *
25  * @author Robert Varga
26  */
27 @NonNullByDefault
28 final class RenameMappingException extends IllegalStateException {
29     private static final long serialVersionUID = 1L;
30
31     private final JavaTypeName name;
32     private final transient SchemaNode definition;
33
34     RenameMappingException(final JavaTypeName name, final SchemaNode definition) {
35         super("Remap " + name + " occupant " + definition);
36         this.name = requireNonNull(name);
37         this.definition = requireNonNull(definition);
38     }
39
40     JavaTypeName getName() {
41         return name;
42     }
43
44     SchemaNode getDefinition() {
45         return definition;
46     }
47 }