Fixup Augmentable and Identifiable methods changing
[netvirt.git] / aclservice / impl / src / test / java / org / opendaylight / netvirt / aclservice / tests / IdentifiedPortSubnetBuilder.java
1 /*
2  * Copyright (c) 2017 Red Hat, 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.netvirt.aclservice.tests;
9
10 import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
11
12 import java.util.ArrayList;
13 import java.util.List;
14 import javax.annotation.concurrent.NotThreadSafe;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.netvirt.aclservice.tests.infra.DataTreeIdentifierDataObjectPairBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.PortSubnets;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnet;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnetBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnetKey;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23
24 @NotThreadSafe
25 public class IdentifiedPortSubnetBuilder implements DataTreeIdentifierDataObjectPairBuilder<PortSubnet>  {
26
27     private String newInterfaceName;
28     private final List<SubnetInfo> subnetInfoList = new ArrayList<>();
29
30     @Override
31     public PortSubnet dataObject() {
32         return new PortSubnetBuilder()
33             .withKey(new PortSubnetKey(newInterfaceName))
34             .setPortId(newInterfaceName)
35             .setSubnetInfo(subnetInfoList)
36             .build();
37     }
38
39     @Override
40     public InstanceIdentifier<PortSubnet> identifier() {
41         return InstanceIdentifier.builder(PortSubnets.class)
42                     .child(PortSubnet.class, new PortSubnetKey(newInterfaceName)).build();
43     }
44
45     @Override
46     public LogicalDatastoreType type() {
47         return OPERATIONAL;
48     }
49
50     public IdentifiedPortSubnetBuilder interfaceName(String interfaceName) {
51         this.newInterfaceName = interfaceName;
52         return this;
53     }
54
55     public IdentifiedPortSubnetBuilder addAllSubnetInfo(List<SubnetInfo> addToSubnetInfoList) {
56         this.subnetInfoList.addAll(addToSubnetInfoList);
57         return this;
58     }
59
60 }