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 static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ClassToInstanceMap;
13 import com.google.common.collect.ImmutableClassToInstanceMap;
14 import java.util.Optional;
15 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
16 import org.opendaylight.mdsal.dom.api.DOMService;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 public final class SimpleDOMMountPoint implements DOMMountPoint {
21 private final YangInstanceIdentifier identifier;
22 private final ClassToInstanceMap<DOMService> services;
24 private SimpleDOMMountPoint(final YangInstanceIdentifier identifier,
25 final ClassToInstanceMap<DOMService> services) {
26 this.identifier = requireNonNull(identifier);
27 this.services = ImmutableClassToInstanceMap.copyOf(services);
30 public static SimpleDOMMountPoint create(final YangInstanceIdentifier identifier,
31 final ClassToInstanceMap<DOMService> services) {
32 return new SimpleDOMMountPoint(identifier, services);
36 public YangInstanceIdentifier getIdentifier() {
41 public <T extends DOMService> Optional<T> getService(final Class<T> cls) {
42 return Optional.ofNullable(services.getInstance(cls));