33f811c739436a5497a5fe8d55766e102ef513bb
[controller.git] / opendaylight / config / config-api / src / main / java / org / opendaylight / controller / config / api / jmx / CommitStatus.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.controller.config.api.jmx;
9
10 import java.beans.ConstructorProperties;
11 import java.util.Collections;
12 import java.util.List;
13 import javax.annotation.concurrent.Immutable;
14 import javax.management.ObjectName;
15
16 @Immutable
17 public class CommitStatus {
18     private final List<ObjectName> newInstances, reusedInstances,
19         recreatedInstances;
20
21     /**
22      * @param newInstances       newly created instances
23      * @param reusedInstances    reused instances
24      * @param recreatedInstances recreated instances
25      */
26     @ConstructorProperties({"newInstances", "reusedInstances",
27             "recreatedInstances"})
28     public CommitStatus(final List<ObjectName> newInstances,
29                         final List<ObjectName> reusedInstances,
30                         final List<ObjectName> recreatedInstances) {
31         this.newInstances = Collections.unmodifiableList(newInstances);
32         this.reusedInstances = Collections.unmodifiableList(reusedInstances);
33         this.recreatedInstances = Collections
34                 .unmodifiableList(recreatedInstances);
35     }
36
37     /**
38      * @return list of objectNames representing newly created instances
39      */
40     public List<ObjectName> getNewInstances() {
41         return newInstances;
42     }
43
44     /**
45      * @return list of objectNames representing reused instances
46      */
47     public List<ObjectName> getReusedInstances() {
48         return reusedInstances;
49     }
50
51     /**
52      * @return list of objectNames representing recreated instances
53      */
54     public List<ObjectName> getRecreatedInstances() {
55         return recreatedInstances;
56     }
57
58     @Override
59     public int hashCode() {
60         final int prime = 31;
61         int result = 1;
62         result = prime * result
63                 + ((newInstances == null) ? 0 : newInstances.hashCode());
64         result = prime
65                 * result
66                 + ((recreatedInstances == null) ? 0 : recreatedInstances
67                 .hashCode());
68         result = prime * result
69                 + ((reusedInstances == null) ? 0 : reusedInstances.hashCode());
70         return result;
71     }
72
73     @Override
74     public boolean equals(final Object obj) {
75         if (this == obj) {
76             return true;
77         }
78         if (obj == null) {
79             return false;
80         }
81         if (getClass() != obj.getClass()) {
82             return false;
83         }
84         CommitStatus other = (CommitStatus) obj;
85         if (newInstances == null) {
86             if (other.newInstances != null) {
87                 return false;
88             }
89         } else if (!newInstances.equals(other.newInstances)) {
90             return false;
91         }
92         if (recreatedInstances == null) {
93             if (other.recreatedInstances != null) {
94                 return false;
95             }
96         } else if (!recreatedInstances.equals(other.recreatedInstances)) {
97             return false;
98         }
99         if (reusedInstances == null) {
100             if (other.reusedInstances != null) {
101                 return false;
102             }
103         } else if (!reusedInstances.equals(other.reusedInstances)) {
104             return false;
105         }
106         return true;
107     }
108
109     @Override
110     public String toString() {
111         return "CommitStatus [newInstances=" + newInstances
112                 + ", reusedInstances=" + reusedInstances
113                 + ", recreatedInstances=" + recreatedInstances + "]";
114     }
115
116 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.