BUG 3057 - notify added event source by topics created before
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / codegen / impl / RuntimeGeneratedInvokerPrototype.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.sal.binding.codegen.impl;
9
10 import java.util.Set;
11
12 import org.opendaylight.controller.sal.binding.api.NotificationListener;
13 import org.opendaylight.yangtools.yang.binding.Notification;
14
15 import com.google.common.base.Objects;
16 import com.google.common.base.Preconditions;
17
18 final class RuntimeGeneratedInvokerPrototype {
19     private final Set<Class<? extends Notification>> supportedNotifications;
20     private final Class<? extends NotificationListener<?>> protoClass;
21
22     public RuntimeGeneratedInvokerPrototype(final Set<Class<? extends Notification>> supportedNotifications, final Class<? extends NotificationListener<?>> protoClass) {
23         this.supportedNotifications = Preconditions.checkNotNull(supportedNotifications);
24         this.protoClass = Preconditions.checkNotNull(protoClass);
25     }
26
27     public Set<Class<? extends Notification>> getSupportedNotifications() {
28         return supportedNotifications;
29     }
30
31     public Class<? extends NotificationListener<?>> getProtoClass() {
32         return protoClass;
33     }
34
35     @Override
36     public int hashCode() {
37         final int prime = 31;
38         int result = 1;
39         result = prime * result + supportedNotifications.hashCode();
40         result = prime * result + protoClass.hashCode();
41         return result;
42     }
43
44     @Override
45     public boolean equals(final Object obj) {
46         if (this == obj) {
47             return true;
48         }
49         if (!(obj instanceof RuntimeGeneratedInvokerPrototype)) {
50             return false;
51         }
52         final RuntimeGeneratedInvokerPrototype other = (RuntimeGeneratedInvokerPrototype) obj;
53         if (!protoClass.equals(other.protoClass)) {
54             return false;
55         }
56         return supportedNotifications.equals(other.supportedNotifications);
57     }
58
59     @Override
60     public String toString() {
61         return Objects.toStringHelper(this)
62                 .add("protoClass", protoClass)
63                 .add("supportedNotifications", supportedNotifications)
64                 .toString();
65     }
66 }