001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.util.comparator;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.model.PortletCategory;
019    
020    import java.io.Serializable;
021    
022    import java.util.Comparator;
023    import java.util.Locale;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class PortletCategoryComparator
029            implements Comparator<PortletCategory>, Serializable {
030    
031            public PortletCategoryComparator(Locale locale) {
032                    _locale = locale;
033            }
034    
035            @Override
036            public int compare(
037                    PortletCategory portletCategory1, PortletCategory portletCategory2) {
038    
039                    String name1 = LanguageUtil.get(_locale, portletCategory1.getName());
040    
041                    String name2 = LanguageUtil.get(_locale, portletCategory2.getName());
042    
043                    return name1.compareTo(name2);
044            }
045    
046            private Locale _locale;
047    
048    }