001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with 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,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    package org.apache.felix.framework.util;
020    
021    import org.osgi.framework.BundleContext;
022    import org.osgi.framework.ServiceListener;
023    import org.osgi.framework.hooks.service.ListenerHook;
024    
025    public class ListenerHookInfoImpl implements ListenerHook.ListenerInfo
026    {
027        private final BundleContext m_context;
028        private final ServiceListener m_listener;
029        private final String m_filter;
030        private boolean m_removed;
031    
032        public ListenerHookInfoImpl(BundleContext context, ServiceListener listener, String filter, boolean removed)
033        {
034            m_context = context;
035            m_listener = listener;
036            m_filter = filter;
037            m_removed = removed;
038        }
039    
040        public BundleContext getBundleContext()
041        {
042            return m_context;
043        }
044    
045        public String getFilter()
046        {
047            return m_filter;
048        }
049    
050        public boolean isRemoved()
051        {
052            return m_removed;
053        }
054    
055        public boolean equals(Object obj) 
056        {
057            if (obj == this) 
058            {
059                return true;
060            }
061            
062            if (!(obj instanceof ListenerHookInfoImpl)) 
063            {
064                return false;
065            }
066            
067            ListenerHookInfoImpl other = (ListenerHookInfoImpl) obj;
068            return other.m_listener == m_listener &&
069                (m_filter == null ? other.m_filter == null : m_filter.equals(other.m_filter));
070        }
071    
072        public int hashCode() 
073        {
074            int rc = 17;
075            
076            rc = 37 * rc + m_listener.hashCode();
077            if (m_filter != null)
078            {
079                rc = 37 * rc + m_filter.hashCode();
080            }
081            return rc;
082        }
083    }