Fix license header violations in sal-dom-spi
[controller.git] / opendaylight / md-sal / sal-dom-spi / src / main / java / org / opendaylight / controller / md / sal / dom / broker / spi / mount / SimpleDOMMountPoint.java
1 /*
2  * Copyright (c) 2014, 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
9 package org.opendaylight.controller.md.sal.dom.broker.spi.mount;
10
11 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
12 import org.opendaylight.controller.md.sal.dom.api.DOMService;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
15
16 import com.google.common.base.Optional;
17 import com.google.common.collect.ClassToInstanceMap;
18 import com.google.common.collect.ImmutableClassToInstanceMap;
19
20 public class SimpleDOMMountPoint implements DOMMountPoint {
21
22     private final YangInstanceIdentifier identifier;
23     private final ClassToInstanceMap<DOMService> services;
24     private final SchemaContext schemaContext;
25
26     public static final SimpleDOMMountPoint create(final YangInstanceIdentifier identifier, final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
27         return new SimpleDOMMountPoint(identifier, services, ctx);
28     }
29     private SimpleDOMMountPoint(final YangInstanceIdentifier identifier, final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
30         this.identifier = identifier;
31         this.services = ImmutableClassToInstanceMap.copyOf(services);
32         this.schemaContext = ctx;
33     }
34
35     @Override
36     public YangInstanceIdentifier getIdentifier() {
37         return identifier;
38     }
39
40     @Override
41     public SchemaContext getSchemaContext() {
42         return schemaContext;
43     }
44
45     @Override
46     public <T extends DOMService> Optional<T> getService(final Class<T> cls) {
47         return Optional.fromNullable(services.getInstance(cls));
48     }
49 }