2 * Copyright (c) 2014, 2015 Cisco Systems, 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.collect.ClassToInstanceMap;
11 import com.google.common.collect.ImmutableClassToInstanceMap;
12 import java.util.Optional;
13 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
14 import org.opendaylight.mdsal.dom.api.DOMService;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 public final class SimpleDOMMountPoint implements DOMMountPoint {
20 private final YangInstanceIdentifier identifier;
21 private final ClassToInstanceMap<DOMService> services;
22 private final SchemaContext schemaContext;
24 private SimpleDOMMountPoint(final YangInstanceIdentifier identifier,
25 final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
26 this.identifier = identifier;
27 this.services = ImmutableClassToInstanceMap.copyOf(services);
28 this.schemaContext = ctx;
31 public static SimpleDOMMountPoint create(final YangInstanceIdentifier identifier,
32 final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
33 return new SimpleDOMMountPoint(identifier, services, ctx);
37 public YangInstanceIdentifier getIdentifier() {
42 public SchemaContext getSchemaContext() {
47 public <T extends DOMService> Optional<T> getService(final Class<T> cls) {
48 return Optional.ofNullable(services.getInstance(cls));