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.portlet.documentlibrary.display.context;
016    
017    import com.liferay.portal.kernel.util.Validator;
018    import com.liferay.registry.ServiceReference;
019    
020    /**
021     * @author Iv??n Zaera
022     */
023    public class DLDisplayContextFactoryReference
024            implements Comparable<DLDisplayContextFactoryReference> {
025    
026            public DLDisplayContextFactoryReference(
027                    DLDisplayContextFactory dlDisplayContextFactory,
028                    ServiceReference<DLDisplayContextFactory> serviceReference) {
029    
030                    _dlDisplayContextFactory = dlDisplayContextFactory;
031                    _serviceReference = serviceReference;
032            }
033    
034            @Override
035            public int compareTo(DLDisplayContextFactoryReference that) {
036                    return _serviceReference.compareTo(that._serviceReference);
037            }
038    
039            @Override
040            public boolean equals(Object obj) {
041                    if (this == obj) {
042                            return true;
043                    }
044    
045                    if (!(obj instanceof DLDisplayContextFactoryReference)) {
046                            return false;
047                    }
048    
049                    DLDisplayContextFactoryReference dlDisplayContextFactoryReference =
050                            (DLDisplayContextFactoryReference)obj;
051    
052                    if (Validator.equals(
053                                    _serviceReference,
054                                    dlDisplayContextFactoryReference._serviceReference)) {
055    
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            public DLDisplayContextFactory getDLDisplayContextFactory() {
063                    return _dlDisplayContextFactory;
064            }
065    
066            public ServiceReference<DLDisplayContextFactory> getServiceReference() {
067                    return _serviceReference;
068            }
069    
070            @Override
071            public int hashCode() {
072                    return _serviceReference.hashCode();
073            }
074    
075            private final DLDisplayContextFactory _dlDisplayContextFactory;
076            private final ServiceReference<DLDisplayContextFactory> _serviceReference;
077    
078    }