tapaas: tapaas support
[neutron.git] / transcriber / src / main / java / org / opendaylight / neutron / transcriber / NeutronTapServiceInterface.java
1 /*
2  * Copyright (c) 2017 Intel Corporation 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.neutron.transcriber;
10
11 import java.util.List;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.neutron.spi.INeutronTapServiceCRUD;
14 import org.opendaylight.neutron.spi.NeutronTapService;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.tapaas.rev171024.tap.services.attributes.TapServices;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.tapaas.rev171024.tap.services.attributes.tap.services.TapService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.tapaas.rev171024.tap.services.attributes.tap.services.TapServiceBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.tapaas.rev171024.tap.services.attributes.tap.services.TapServiceKey;
19
20
21
22 public final class NeutronTapServiceInterface
23         extends AbstractNeutronInterface<TapService, TapServices, TapServiceKey, NeutronTapService>
24         implements INeutronTapServiceCRUD {
25     NeutronTapServiceInterface(DataBroker db) {
26         super(TapServiceBuilder.class, db);
27     }
28
29     @Override
30     protected List<TapService> getDataObjectList(TapServices services) {
31         return services.getTapService();
32     }
33
34     @Override
35     protected NeutronTapService fromMd(TapService service) {
36         final NeutronTapService answer = new NeutronTapService();
37         fromMdBaseAttributes(service, answer);
38         if (service.getPortId() != null) {
39             answer.setTapServicePortID(service.getPortId().getValue());
40         }
41         return answer;
42     }
43
44     @Override
45     protected TapService toMd(NeutronTapService service) {
46         final TapServiceBuilder serviceBuilder = new TapServiceBuilder();
47         toMdBaseAttributes(service, serviceBuilder);
48         if (service.getTapServicePortID() != null) {
49             serviceBuilder.setPortId(toUuid(service.getTapServicePortID()));
50         }
51         return serviceBuilder.build();
52     }
53 }