001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.cache.configuration;
016    
017    import com.liferay.portal.kernel.cache.CallbackFactory;
018    import com.liferay.portal.kernel.util.HashUtil;
019    
020    import java.util.Properties;
021    
022    /**
023     * @author Tina Tian
024     */
025    public class CallbackConfiguration {
026    
027            public CallbackConfiguration(
028                    CallbackFactory callbackFactory, Properties properties) {
029    
030                    if (callbackFactory == null) {
031                            throw new NullPointerException("Callback factory is null");
032                    }
033    
034                    if (properties == null) {
035                            throw new NullPointerException("Properties is null");
036                    }
037    
038                    _callbackFactory = callbackFactory;
039                    _properties = (Properties)properties.clone();
040            }
041    
042            @Override
043            public boolean equals(Object object) {
044                    if (this == object) {
045                            return true;
046                    }
047    
048                    if (!(object instanceof CallbackConfiguration)) {
049                            return false;
050                    }
051    
052                    CallbackConfiguration callbackConfiguration =
053                            (CallbackConfiguration)object;
054    
055                    if ((_callbackFactory == callbackConfiguration._callbackFactory) &&
056                            _properties.equals(callbackConfiguration._properties)) {
057    
058                            return true;
059                    }
060    
061                    return false;
062            }
063    
064            public CallbackFactory getCallbackFactory() {
065                    return _callbackFactory;
066            }
067    
068            public Properties getProperties() {
069                    return (Properties)_properties.clone();
070            }
071    
072            @Override
073            public int hashCode() {
074                    int hash = HashUtil.hash(0, _callbackFactory);
075    
076                    return HashUtil.hash(hash, _properties);
077            }
078    
079            private final CallbackFactory _callbackFactory;
080            private final Properties _properties;
081    
082    }