Introduce top-level pom file.
[mdsal.git] / code-generator / binding-data-codec / src / main / java / org / opendaylight / yangtools / binding / data / codec / impl / MissingClassInLoadingStrategyException.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.yangtools.binding.data.codec.impl;
9
10 import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
11
12 /**
13  *
14  * Thrown when user schema for supplied binding class is available in present schema context, but
15  * binding class itself is not known to codecs because backing class loading strategy did not
16  * provided it.
17  *
18  */
19 public class MissingClassInLoadingStrategyException extends MissingSchemaException {
20
21     private static final long serialVersionUID = 1L;
22
23     protected MissingClassInLoadingStrategyException(final String msg, final Throwable cause) {
24         super(msg, cause);
25     }
26
27     public static void check(final ClassLoadingStrategy strategy, final Class<?> childClass) {
28         try {
29             strategy.loadClass(childClass.getName());
30         } catch (final ClassNotFoundException e) {
31             final String message =
32                     String.format("User supplied class %s is not available in %s.", childClass.getName(), strategy);
33             throw new MissingClassInLoadingStrategyException(message, e);
34         }
35     }
36
37 }