Use SyncupEntry in syncup method (Bug 6170 cleaning)
[openflowplugin.git] / applications / forwardingrules-sync / src / main / java / org / opendaylight / openflowplugin / applications / frsync / util / SyncupEntry.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 org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
13
14 /**
15  * Data entry of before and after data for syncup in {@link org.opendaylight.openflowplugin.applications.frsync.SyncReactor}.
16  */
17 public class SyncupEntry {
18     private final FlowCapableNode after;
19     private final LogicalDatastoreType dsTypeAfter;
20     private final FlowCapableNode before;
21     private final LogicalDatastoreType dsTypeBefore;
22
23     public SyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter,
24                        final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
25         this.after = after;
26         this.dsTypeAfter = dsTypeAfter;
27         this.before = before;
28         this.dsTypeBefore = dsTypeBefore;
29     }
30
31     public FlowCapableNode getAfter() {
32         return after;
33     }
34
35     public FlowCapableNode getBefore() {
36         return before;
37     }
38
39     public LogicalDatastoreType getDsTypeAfter() {
40         return dsTypeAfter;
41     }
42
43     public LogicalDatastoreType getDsTypeBefore() {
44         return dsTypeBefore;
45     }
46
47     public boolean isOptimizedConfigDelta() {
48         return dsTypeAfter == LogicalDatastoreType.CONFIGURATION && dsTypeBefore == LogicalDatastoreType.CONFIGURATION;
49     }
50
51     @Override
52     public boolean equals(Object o) {
53         if (this == o) return true;
54         if (o == null || getClass() != o.getClass()) return false;
55
56         SyncupEntry that = (SyncupEntry) o;
57
58         if (after != null ? !after.equals(that.after) : that.after != null) return false;
59         if (dsTypeAfter != that.dsTypeAfter) return false;
60         if (before != null ? !before.equals(that.before) : that.before != null) return false;
61         return dsTypeBefore == that.dsTypeBefore;
62     }
63
64 }