/*
 * JBoss, Home of Professional Open Source
 * Copyright 2010, Red Hat, Inc., and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jboss.weld.ejb.spi.helpers;

import java.lang.reflect.Method;
import java.util.Collection;

import org.jboss.weld.ejb.spi.BusinessInterfaceDescriptor;
import org.jboss.weld.ejb.spi.EjbDescriptor;

/**
 * An implementation of {@link EjbDescriptor} which forwards all its method calls to another {@link EjbDescriptor} . Subclasses
 * should override one or more methods to modify the behavior of the backing {@link EjbDescriptor} as desired per the <a
 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
 *
 * @author Pete Muir
 *
 */
public abstract class ForwardingEjbDescriptor<T> implements EjbDescriptor<T> {

    protected abstract EjbDescriptor<T> delegate();

    public Collection<BusinessInterfaceDescriptor<?>> getLocalBusinessInterfaces() {
        return delegate().getLocalBusinessInterfaces();
    }

    public Collection<BusinessInterfaceDescriptor<?>> getRemoteBusinessInterfaces() {
        return delegate().getRemoteBusinessInterfaces();
    }

    public Collection<Method> getRemoveMethods() {
        return delegate().getRemoveMethods();
    }

    public Class<T> getBeanClass() {
        return delegate().getBeanClass();
    }

    public String getEjbName() {
        return delegate().getEjbName();
    }

    public boolean isMessageDriven() {
        return delegate().isMessageDriven();
    }

    public boolean isSingleton() {
        return delegate().isSingleton();
    }

    public boolean isStateful() {
        return delegate().isStateful();
    }

    public boolean isStateless() {
        return delegate().isStateless();
    }

    @Override
    public boolean isPassivationCapable() {
        return delegate().isPassivationCapable();
    }

    @Override
    public boolean equals(Object obj) {
        return this == obj || delegate().equals(obj);
    }

    @Override
    public String toString() {
        return delegate().toString();
    }

    @Override
    public int hashCode() {
        return delegate().hashCode();
    }

}

@@ -1475,16 +1475,30 @@
 ate();%0A%0A
+    @Override%0A
     publ
@@ -1566,32 +1566,32 @@
 sInterfaces() %7B%0A
-
         return d
@@ -1629,32 +1629,46 @@
 faces();%0A    %7D%0A%0A
+    @Override%0A
     public Colle
@@ -1793,32 +1793,46 @@
 faces();%0A    %7D%0A%0A
+    @Override%0A
     public Colle
@@ -1911,32 +1911,46 @@
 thods();%0A    %7D%0A%0A
+    @Override%0A
     public Class
@@ -2011,32 +2011,46 @@
 Class();%0A    %7D%0A%0A
+    @Override%0A
     public Strin
@@ -2105,32 +2105,46 @@
 bName();%0A    %7D%0A%0A
+    @Override%0A
     public boole
@@ -2210,32 +2210,46 @@
 riven();%0A    %7D%0A%0A
+    @Override%0A
     public boole
@@ -2307,32 +2307,46 @@
 leton();%0A    %7D%0A%0A
+    @Override%0A
     public boole
@@ -2406,24 +2406,38 @@
 l();%0A    %7D%0A%0A
+    @Override%0A
     public b
@@ -2688,29 +2688,233 @@
     
-return this == obj %7C%7C
+if (this == obj) %7B%0A            return true;%0A        %7D%0A        if (obj instanceof ForwardingEjbDescriptor%3C?%3E) %7B%0A            return delegate().equals(ForwardingEjbDescriptor.class.cast(obj).delegate());%0A        %7D%0A        return
  del
@@ -3111,17 +3111,16 @@
 Code();%0A
+
     %7D%0A
-%0A
 %7D%0A

Fix ForwardingEjbDescriptor.equals()