Promote codec exceptions to binding.codec.api
[mdsal.git] / binding / mdsal-binding-dom-codec-api / src / main / java / org / opendaylight / mdsal / binding / dom / codec / api / MissingSchemaForClassException.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.dom.codec.api;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
14 import org.eclipse.jdt.annotation.Nullable;
15
16 /**
17  * Thrown when Java Binding class was used in data for which codec does not have schema.
18  *
19  * <p>
20  * By serialization /  deserialization of this exception {@link #getBindingClass()} will return null.
21  */
22 @Beta
23 public final class MissingSchemaForClassException extends MissingSchemaException {
24     private static final long serialVersionUID = 1L;
25
26     @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Documented in API contract")
27     private final transient Class<?> bindingClass;
28
29     public MissingSchemaForClassException(final Class<?> clz) {
30         super(String.format("Schema is not available for %s", clz));
31         this.bindingClass = requireNonNull(clz);
32     }
33
34     public @Nullable Class<?> getBindingClass() {
35         return bindingClass;
36     }
37 }