Deprecate all MD-SAL APIs
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / impl / SchemaContextProviders.java
1 /*
2  * Copyright (c) 2013 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.controller.sal.dom.broker.impl;
9
10 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
11 import org.opendaylight.yangtools.concepts.Delegator;
12 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
14
15 @Deprecated
16 public final class SchemaContextProviders {
17
18     private SchemaContextProviders() {
19         throw new UnsupportedOperationException("Utility class.");
20     }
21
22     public static SchemaContextProvider fromSchemaService(final DOMSchemaService schemaService) {
23         if (schemaService instanceof SchemaContextProvider) {
24             return (SchemaContextProvider) schemaService;
25         }
26         return new SchemaServiceAdapter(schemaService);
27     }
28
29     private static final class SchemaServiceAdapter implements SchemaContextProvider, Delegator<DOMSchemaService> {
30
31         private final DOMSchemaService service;
32
33         SchemaServiceAdapter(final DOMSchemaService service) {
34             this.service = service;
35         }
36
37         @Override
38         public SchemaContext getSchemaContext() {
39             return service.getGlobalContext();
40         }
41
42         @Override
43         public DOMSchemaService getDelegate() {
44             return service;
45         }
46
47         @Override
48         public String toString() {
49             return "SchemaServiceAdapter [service=" + service + "]";
50         }
51     }
52 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.