Fix checkstyle violations in applications
[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
16  * {@link org.opendaylight.openflowplugin.applications.frsync.SyncReactor}.
17  */
18 public class SyncupEntry {
19     private final FlowCapableNode after;
20     private final LogicalDatastoreType dsTypeAfter;
21     private final FlowCapableNode before;
22     private final LogicalDatastoreType dsTypeBefore;
23
24     public SyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter,
25                        final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
26         this.after = after;
27         this.dsTypeAfter = dsTypeAfter;
28         this.before = before;
29         this.dsTypeBefore = dsTypeBefore;
30     }
31
32     public FlowCapableNode getAfter() {
33         return after;
34     }
35
36     public FlowCapableNode getBefore() {
37         return before;
38     }
39
40     public LogicalDatastoreType getDsTypeAfter() {
41         return dsTypeAfter;
42     }
43
44     public LogicalDatastoreType getDsTypeBefore() {
45         return dsTypeBefore;
46     }
47
48     public boolean isOptimizedConfigDelta() {
49         return dsTypeAfter == LogicalDatastoreType.CONFIGURATION && dsTypeBefore == LogicalDatastoreType.CONFIGURATION;
50     }
51
52     @Override
53     public boolean equals(Object obj) {
54         if (this == obj) {
55             return true;
56         }
57         if (obj == null || getClass() != obj.getClass()) {
58             return false;
59         }
60
61         SyncupEntry that = (SyncupEntry) obj;
62
63         if (after != null ? !after.equals(that.after) : that.after != null) {
64             return false;
65         }
66         if (dsTypeAfter != that.dsTypeAfter) {
67             return false;
68         }
69         if (before != null ? !before.equals(that.before) : that.before != null) {
70             return false;
71         }
72         return dsTypeBefore == that.dsTypeBefore;
73     }
74
75     @Override
76     public int hashCode() {
77         final int prime = 31;
78         int result = after != null ? after.hashCode() : 0;
79         result = prime * result + (dsTypeAfter != null ? dsTypeAfter.hashCode() : 0);
80         result = prime * result + (before != null ? before.hashCode() : 0);
81         result = prime * result + (dsTypeBefore != null ? dsTypeBefore.hashCode() : 0);
82         return result;
83     }
84
85 }