2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.dom.codec.impl;
10 import static java.util.Objects.requireNonNull;
12 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13 import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
14 import org.opendaylight.yangtools.yang.binding.Augmentation;
17 * Thrown when Java Binding class was used in data for which codec does not have schema.
20 * By serialization / deserialization of this exception {@link #getBindingClass()} will return null.
22 public final class MissingSchemaForClassException extends MissingSchemaException {
24 private static final long serialVersionUID = 1L;
26 @SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED")
27 private final transient Class<?> bindingClass;
29 private MissingSchemaForClassException(final Class<?> clz) {
30 super(String.format("Schema is not available for %s", clz));
31 this.bindingClass = requireNonNull(clz);
34 static MissingSchemaForClassException forClass(final Class<?> clz) {
35 return new MissingSchemaForClassException(clz);
38 public Class<?> getBindingClass() {
42 public static void check(final BindingRuntimeContext runtimeContext, final Class<?> bindingClass) {
44 if (Augmentation.class.isAssignableFrom(bindingClass)) {
45 schema = runtimeContext.getAugmentationDefinition(bindingClass);
47 schema = runtimeContext.getSchemaDefinition(bindingClass);
50 throw MissingSchemaForClassException.forClass(bindingClass);