001    /**
002     *
003     *  Licensed to the Apache Software Foundation (ASF) under one or more
004     *  contributor license agreements.  See the NOTICE file distributed with
005     *  this work for additional information regarding copyright ownership.
006     *  The ASF licenses this file to You under the Apache License, Version 2.0
007     *  (the "License"); you may not use this file except in compliance with
008     *  the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *  Unless required by applicable law or agreed to in writing, software
013     *  distributed under the License is distributed on an "AS IS" BASIS,
014     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     *  See the License for the specific language governing permissions and
016     *  limitations under the License.
017     */
018    package org.apache.geronimo.j2ee.deployment;
019    
020    import java.io.Serializable;
021    
022    /**
023     * @version $Revision: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
024     */
025    public final class EJBRefInfo implements Serializable {
026        private final boolean isLocal;
027        private final boolean isSession;
028        private final String homeIntf;
029        private final String beanIntf;
030    
031        public EJBRefInfo(boolean local, boolean session, String homeIntf, String beanIntf) {
032            assert homeIntf != null: "homeIntf is null";
033            assert beanIntf != null: "beanIntf is null";
034            isLocal = local;
035            isSession = session;
036            this.homeIntf = homeIntf;
037            this.beanIntf = beanIntf;
038        }
039    
040        public boolean isLocal() {
041            return isLocal;
042        }
043    
044        public boolean isSession() {
045            return isSession;
046        }
047    
048        public String getHomeIntf() {
049            return homeIntf;
050        }
051    
052        public String getBeanIntf() {
053            return beanIntf;
054        }
055    
056        public boolean equals(Object object) {
057            if (!(object instanceof EJBRefInfo)) {
058                return false;
059            }
060    
061            // match isSession
062            EJBRefInfo ejbRefInfo = (EJBRefInfo) object;
063            return ejbRefInfo.isLocal == isLocal &&
064                    ejbRefInfo.isSession == isSession &&
065                    ejbRefInfo.homeIntf.equals(homeIntf) &&
066                    ejbRefInfo.beanIntf.equals(beanIntf);
067        }
068    
069        public int hashCode() {
070            int result = 17;
071            result = 37 * result + (isLocal ? 1 : 0);
072            result = 37 * result + (isSession ? 1 : 0);
073            result = 37 * result + homeIntf.hashCode();
074            result = 37 * result + beanIntf.hashCode();
075            return result;
076        }
077    }