3365d591aaea7195a48f3fce11e2e1f96cdc4516
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / apps / route / impl / src / main / java / com / highstreet / technologies / odl / app / impl / PathHolder.java
1 /*
2  * Copyright © 2015 ZTE 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 com.highstreet.technologies.odl.app.impl;
9
10 import com.highstreet.technologies.odl.app.impl.delegates.LtpInOdlCreator;
11 import com.highstreet.technologies.odl.app.impl.delegates.PathDelegate;
12 import com.highstreet.technologies.odl.app.impl.tools.NeExecutor;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
15
16 import java.util.ArrayList;
17
18 /**
19  * Created by odl on 17-6-2.
20  */
21 public class PathHolder
22 {
23     public PathHolder(DataBroker dataBroker, Integer vlanId)
24     {
25         this.pathDelegate = new PathDelegate(dataBroker, vlanId);
26     }
27
28     private final PathDelegate pathDelegate;
29     private ArrayList<NeExecutor> list = new ArrayList<>();
30     private LtpInOdlCreator ltpCreator = new LtpInOdlCreator();
31
32     public void add(NeExecutor to)
33     {
34         list.add(to);
35         pathDelegate.add(to.getLtp());
36     }
37
38     public void commit() throws TransactionCommitFailedException
39     {
40         list.forEach(NeExecutor::commit);
41         pathDelegate.commit();
42     }
43
44     public void clear(int vlanId) throws TransactionCommitFailedException
45     {
46         list.forEach(neExecutor -> neExecutor.clear(vlanId));
47         pathDelegate.clear();
48     }
49
50     public LtpInOdlCreator getLtpCreator()
51     {
52         return ltpCreator;
53     }
54 }