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.suggest;
016    
017    import java.util.Collections;
018    import java.util.HashMap;
019    import java.util.Map;
020    
021    /**
022     * @author Michael C. Han
023     */
024    public class AggregateSuggester implements Suggester {
025    
026            public AggregateSuggester(String name, String value) {
027                    _name = name;
028                    _value = value;
029            }
030    
031            @Override
032            public <T> T accept(SuggesterVisitor<T> suggesterVisitor) {
033                    return suggesterVisitor.visit(this);
034            }
035    
036            public void addSuggester(Suggester suggester) {
037                    _suggesters.put(suggester.getName(), suggester);
038            }
039    
040            @Override
041            public String getName() {
042                    return _name;
043            }
044    
045            public Map<String, Suggester> getSuggesters() {
046                    return Collections.unmodifiableMap(_suggesters);
047            }
048    
049            public String getValue() {
050                    return _value;
051            }
052    
053            private final String _name;
054            private final Map<String, Suggester> _suggesters = new HashMap<>();
055            private final String _value;
056    
057    }