9319f79e733b9e105ab19030a9e81eab3e3dffa3
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / modification / CompositeModification.java
1 /*
2  * Copyright (c) 2014 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
9 package org.opendaylight.controller.cluster.datastore.modification;
10
11 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
12
13 import java.util.ArrayList;
14 import java.util.List;
15
16 /**
17  * CompositeModification contains a list of modifications that need to be applied to the DOMStore
18  * <p>
19  * A CompositeModification gets stored in the transaction log for a Shard. During recovery when the transaction log
20  * is being replayed a DOMStoreWriteTransaction could be created and a CompositeModification could be applied to it.
21  * </p>
22  */
23 public class CompositeModification implements Modification {
24   private final List<Modification> modifications = new ArrayList<>();
25
26   @Override
27   public void apply(DOMStoreWriteTransaction transaction) {
28     for(Modification modification : modifications){
29       modification.apply(transaction);
30     }
31   }
32
33   public void addModification(Modification modification){
34     modifications.add(modification);
35   }
36 }