2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.binding.codegen.impl;
12 import org.eclipse.xtext.xbase.lib.util.ToStringHelper;
13 import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper;
14 import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker;
15 import org.opendaylight.yangtools.yang.binding.Notification;
16 import org.opendaylight.yangtools.yang.binding.NotificationListener;
18 import com.google.common.base.Preconditions;
20 final class RuntimeGeneratedInvoker implements NotificationInvoker {
21 private final org.opendaylight.controller.sal.binding.api.NotificationListener<Notification> invocationProxy;
22 private final RuntimeGeneratedInvokerPrototype prototype;
23 private final NotificationListener delegate;
25 @SuppressWarnings("unchecked")
26 private RuntimeGeneratedInvoker(final NotificationListener delegate, final RuntimeGeneratedInvokerPrototype prototype, final org.opendaylight.controller.sal.binding.api.NotificationListener<?> proxy) {
27 this.invocationProxy = (org.opendaylight.controller.sal.binding.api.NotificationListener<Notification>) proxy;
28 this.delegate = Preconditions.checkNotNull(delegate);
29 this.prototype = prototype;
32 public static RuntimeGeneratedInvoker create(final NotificationListener delegate, final RuntimeGeneratedInvokerPrototype prototype) throws InstantiationException, IllegalAccessException {
33 final org.opendaylight.controller.sal.binding.api.NotificationListener<?> proxy = Preconditions.checkNotNull(prototype.getProtoClass().newInstance());
34 RuntimeCodeHelper.setDelegate(proxy, delegate);
35 return new RuntimeGeneratedInvoker(delegate, prototype, proxy);
39 public NotificationListener getDelegate() {
44 public org.opendaylight.controller.sal.binding.api.NotificationListener<Notification> getInvocationProxy() {
45 return invocationProxy;
49 public Set<Class<? extends Notification>> getSupportedNotifications() {
50 return prototype.getSupportedNotifications();
59 public int hashCode() {
62 result = prime * result + delegate.hashCode();
63 result = prime * result + invocationProxy.hashCode();
64 result = prime * result + prototype.hashCode();
69 public boolean equals(final Object obj) {
73 if (!(obj instanceof RuntimeGeneratedInvoker)) {
76 final RuntimeGeneratedInvoker other = (RuntimeGeneratedInvoker) obj;
77 if (!delegate.equals(other.delegate)) {
80 if (!invocationProxy.equals(other.invocationProxy)) {
83 return prototype.equals(other.prototype);
87 public String toString() {
88 String result = new ToStringHelper().toString(this);