Merge "Sonar issues"
[openflowplugin.git] / applications / forwardingrules-sync / src / main / java / org / opendaylight / openflowplugin / applications / frsync / util / ItemSyncBox.java
1 /**
2  * Copyright (c) 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
9 package org.opendaylight.openflowplugin.applications.frsync.util;
10
11 import java.util.LinkedHashSet;
12 import java.util.Set;
13
14 /**
15  * Holder for items to be pushed to device.
16  * Contains two sets of groups -set of items to be pushed and set of tuples for update.
17  */
18 public class ItemSyncBox<I> {
19
20     private final Set<I> itemsToPush = new LinkedHashSet<>();
21     private final Set<ItemUpdateTuple<I>> itemsToUpdate = new LinkedHashSet<>();
22
23     public Set<I> getItemsToPush() {
24         return itemsToPush;
25     }
26
27     public Set<ItemUpdateTuple<I>> getItemsToUpdate() {
28         return itemsToUpdate;
29     }
30
31     public boolean isEmpty() {
32         return itemsToPush.isEmpty() && itemsToUpdate.isEmpty();
33     }
34
35     /**
36      * Tuple holder for original and updated item.
37      * @param <I> basic type
38      */
39     public static final class ItemUpdateTuple<I> {
40         private final I original;
41         private final I updated;
42
43         public ItemUpdateTuple(I original, I updated) {
44             this.original = original;
45             this.updated = updated;
46         }
47
48         public I getOriginal() {
49             return original;
50         }
51
52         public I getUpdated() {
53             return updated;
54         }
55     }
56 }