Merge "Protocol framework: use pooled ByteBuf allocator"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / modification / MutableCompositeModification.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.io.Serializable;
14 import java.util.ArrayList;
15 import java.util.Collections;
16 import java.util.List;
17
18 /**
19  * MutableCompositeModification is just a mutable version of a
20  * CompositeModification {@link org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification#addModification(Modification)}
21  */
22 public class MutableCompositeModification
23     implements CompositeModification, Serializable {
24
25     private static final long serialVersionUID = 1163377899140186790L;
26
27     private final List<Modification> modifications = new ArrayList<>();
28
29     @Override
30     public void apply(DOMStoreWriteTransaction transaction) {
31         for (Modification modification : modifications) {
32             modification.apply(transaction);
33         }
34     }
35
36     /**
37      * Add a new Modification to the list of Modifications represented by this
38      * composite
39      *
40      * @param modification
41      */
42     public void addModification(Modification modification) {
43         modifications.add(modification);
44     }
45
46     public List<Modification> getModifications() {
47         return Collections.unmodifiableList(modifications);
48     }
49 }