a5f4dd4229ccba823df694266ab39f0494d8b8ee
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / ovsdb / transact / TransactCommandAggregator.java
1 /*
2  * Copyright (c) 2014, 2016 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.ovsdb.southbound.ovsdb.transact;
9
10 import java.util.Collection;
11 import java.util.function.Supplier;
12 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
13 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
14 import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec;
15 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
16
17 /**
18  * This transactional command aggregates all the Southbound commands.
19  */
20 public class TransactCommandAggregator implements TransactCommand {
21     // Type capture to allow using an array
22     private interface CommandSupplier extends Supplier<TransactCommand> {
23
24     }
25
26     private static final CommandSupplier[] COMMAND_SUPPLIERS = new CommandSupplier[] {
27         BridgeUpdateCommand::new,
28         OpenVSwitchBridgeAddCommand::new,
29         ControllerUpdateCommand::new,
30         ControllerRemovedCommand::new,
31         ProtocolUpdateCommand::new,
32         ProtocolRemovedCommand::new,
33         BridgeRemovedCommand::new,
34         TerminationPointCreateCommand::new,
35         TerminationPointDeleteCommand::new,
36         OvsdbNodeUpdateCommand::new,
37         AutoAttachUpdateCommand::new,
38         AutoAttachRemovedCommand::new,
39         QosUpdateCommand::new,
40         QosRemovedCommand::new,
41         QueueUpdateCommand::new,
42         QueueRemovedCommand::new,
43         TerminationPointUpdateCommand::new
44     };
45
46     @Override
47     public void execute(final TransactionBuilder transaction, final BridgeOperationalState state,
48             final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) {
49         for (CommandSupplier supplier : COMMAND_SUPPLIERS) {
50             supplier.get().execute(transaction, state, events, instanceIdentifierCodec);
51         }
52     }
53
54     @Override
55     public void execute(final TransactionBuilder transaction, final BridgeOperationalState state,
56             final Collection<DataTreeModification<Node>> modifications,
57             final InstanceIdentifierCodec instanceIdentifierCodec) {
58         for (CommandSupplier supplier : COMMAND_SUPPLIERS) {
59             supplier.get().execute(transaction, state, modifications, instanceIdentifierCodec);
60         }
61     }
62 }