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 com.google.common.annotations.Beta;
11 import com.google.common.collect.ClassToInstanceMap;
12 import com.google.common.collect.ImmutableClassToInstanceMap;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
15 import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
16 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
21 * Base class to implement DOMSchemaService more easily while providing a bridge between MD-SAL DOM Schema services
22 * and YANG Tools Schema consumers.
24 * @author Michael Vorburger.ch
28 public abstract class AbstractDOMSchemaService implements DOMSchemaService, SchemaContextProvider {
29 public abstract static class WithYangTextSources extends AbstractDOMSchemaService
30 implements DOMYangTextSourceProvider {
32 public ClassToInstanceMap<DOMSchemaServiceExtension> getExtensions() {
33 return ImmutableClassToInstanceMap.of(DOMYangTextSourceProvider.class, this);
38 public final SchemaContext getSchemaContext() {
39 // Always route context queries to a single method
40 return getGlobalContext();
44 public final SchemaContext getSessionContext() {
45 // This method should not be implemented
46 throw new UnsupportedOperationException();
50 public ClassToInstanceMap<DOMSchemaServiceExtension> getExtensions() {
51 return ImmutableClassToInstanceMap.of();