2 * Copyright (c) 2019 Red Hat, 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.dom.spi;
10 import static com.google.common.base.Preconditions.checkState;
12 import com.google.common.annotations.Beta;
13 import com.google.common.collect.ClassToInstanceMap;
14 import com.google.common.collect.ImmutableClassToInstanceMap;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
17 import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
18 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
19 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
20 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
23 * Base class to implement DOMSchemaService more easily while providing a bridge between MD-SAL DOM Schema services
24 * and YANG Tools Schema consumers.
26 * @author Michael Vorburger.ch
30 public abstract class AbstractDOMSchemaService implements DOMSchemaService, EffectiveModelContextProvider {
31 public abstract static class WithYangTextSources extends AbstractDOMSchemaService
32 implements DOMYangTextSourceProvider {
34 public ClassToInstanceMap<DOMSchemaServiceExtension> getExtensions() {
35 return ImmutableClassToInstanceMap.of(DOMYangTextSourceProvider.class, this);
40 public final EffectiveModelContext getEffectiveModelContext() {
41 final EffectiveModelContext ret = getGlobalContext();
42 checkState(ret != null, "Global context is not available in %s", this);