Fixup Augmentable and Identifiable methods changing
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / utils / ElanEtreeUtils.java
1 /*
2  * Copyright © 2017 Red Hat, Inc. and others.
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.netvirt.elan.utils;
9
10 import com.google.common.base.Optional;
11 import javax.inject.Inject;
12 import javax.inject.Singleton;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagName;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18
19 @Singleton
20 public class ElanEtreeUtils {
21     private final DataBroker broker;
22
23     @Inject
24     public ElanEtreeUtils(DataBroker broker) {
25         this.broker = broker;
26     }
27
28     public EtreeLeafTagName getEtreeLeafTagByElanTag(long elanTag) {
29         InstanceIdentifier<ElanTagName> elanId = ElanUtils.getElanInfoEntriesOperationalDataPath(elanTag);
30         Optional<ElanTagName> existingElanInfo = ElanUtils.read(broker,
31                 LogicalDatastoreType.OPERATIONAL, elanId);
32         if (existingElanInfo.isPresent()) {
33             ElanTagName elanTagName = existingElanInfo.get();
34             return elanTagName.augmentation(EtreeLeafTagName.class);
35         }
36         return null;
37     }
38 }