Bug 2364: Migrated Binding MD-SAL to not use composites nodes
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / compat / HydrogenMountPointServiceAdapter.java
1 /*
2  * Copyright (c) 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 package org.opendaylight.controller.md.sal.binding.compat;
9
10 import com.google.common.base.Optional;
11 import com.google.common.cache.CacheBuilder;
12 import com.google.common.cache.CacheLoader;
13 import com.google.common.cache.LoadingCache;
14 import org.opendaylight.controller.md.sal.binding.api.MountPoint;
15 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
16 import org.opendaylight.controller.sal.binding.api.mount.MountService;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18
19 @Deprecated
20 public class HydrogenMountPointServiceAdapter implements MountService {
21
22     private final MountPointService delegate;
23
24     public HydrogenMountPointServiceAdapter(final MountPointService mountService) {
25         delegate = mountService;
26     }
27
28     private final LoadingCache<MountPoint, HydrogenMountInstanceAdapter> mountAdapters = CacheBuilder.newBuilder().weakKeys()
29             .build(new CacheLoader<MountPoint, HydrogenMountInstanceAdapter>() {
30
31                 @Override
32                 public HydrogenMountInstanceAdapter load(final MountPoint key) throws Exception {
33                     return new HydrogenMountInstanceAdapter(key);
34                 }
35             });
36
37     @Override
38     public HydrogenMountInstanceAdapter getMountPoint(final InstanceIdentifier<?> path) {
39         final Optional<MountPoint> mount = delegate.getMountPoint(path);
40         if (mount.isPresent()) {
41             return mountAdapters.getUnchecked(mount.get());
42         }
43         return null;
44     }
45
46     MountPointService getDelegate() {
47         return delegate;
48     }
49 }

©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.