Merge "Bug 6366 - of-switch-config-pusher - DTCL instead of DTL"
[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) {
54             return true;
55         }
56         if (o == null || getClass() != o.getClass()) {
57             return false;
58         }
59
60         SyncupEntry that = (SyncupEntry) o;
61
62         if (after != null ? !after.equals(that.after) : that.after != null) {
63             return false;
64         }
65         if (dsTypeAfter != that.dsTypeAfter) {
66             return false;
67         }
68         if (before != null ? !before.equals(that.before) : that.before != null) {
69             return false;
70         }
71         return dsTypeBefore == that.dsTypeBefore;
72     }
73
74     @Override
75     public int hashCode() {
76         final int prime = 31;
77         int result = after != null ? after.hashCode() : 0;
78         result = prime * result + (dsTypeAfter != null ? dsTypeAfter.hashCode() : 0);
79         result = prime * result + (before != null ? before.hashCode() : 0);
80         result = prime * result + (dsTypeBefore != null ? dsTypeBefore.hashCode() : 0);
81         return result;
82     }
83
84 }