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.search;
016    
017    import com.liferay.portal.kernel.search.geolocation.GeoLocationPoint;
018    
019    import java.util.ArrayList;
020    import java.util.Arrays;
021    import java.util.Collections;
022    import java.util.List;
023    
024    /**
025     * @author Michael C. Han
026     */
027    public class GeoDistanceSort extends Sort {
028    
029            public GeoDistanceSort() {
030                    setType(GEO_DISTANCE_TYPE);
031            }
032    
033            public void addGeoHash(String geoHash) {
034                    _geoHashes.add(geoHash);
035            }
036    
037            public void addGeoHash(String... geoHashes) {
038                    _geoHashes.addAll(Arrays.asList(geoHashes));
039            }
040    
041            public void addGeoLocationPoint(GeoLocationPoint geoLocationPoint) {
042                    _geoLocationPoints.add(geoLocationPoint);
043            }
044    
045            public void addGeoLocationPoints(GeoLocationPoint... geoLocationPoints) {
046                    _geoLocationPoints.addAll(Arrays.asList(geoLocationPoints));
047            }
048    
049            public List<String> getGeoHashes() {
050                    return Collections.unmodifiableList(_geoHashes);
051            }
052    
053            public List<GeoLocationPoint> getGeoLocationPoints() {
054                    return Collections.unmodifiableList(_geoLocationPoints);
055            }
056    
057            private final List<String> _geoHashes = new ArrayList<>();
058            private final List<GeoLocationPoint> _geoLocationPoints = new ArrayList<>();
059    
060    }