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