001/*
002 *  Copyright 2018 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.web.frontoffice.search.metamodel;
017
018import org.ametys.web.frontoffice.search.metamodel.impl.AbstractParameterAdderReturnable;
019import org.ametys.web.frontoffice.search.metamodel.impl.AbstractParameterAdderSearchable;
020import org.ametys.web.service.ServiceParameter;
021
022/**
023 * This class is a wrapper of an additional parameter for a search service instance
024 * (brought by a {@link Searchable} or a {@link Returnable}, throuh {@link AbstractParameterAdderSearchable} or {@link AbstractParameterAdderReturnable} for instance).
025 * <br>It holds the actual {@link ServiceParameter}, and a boolean indicating if in client-side, the change of the field of this parameter must lead to a reload of the search criteria.
026 * @param <T> Type of the parameter
027 */
028public final class AdditionalSearchServiceParameter<T>
029{
030    private ServiceParameter<T> _serviceParameter;
031    private boolean _reloadCriteriaOnChange;
032
033    /**
034     * Constructs the AdditionalSearchServiceParameter
035     * @param serviceParameter the actual search service additional parameter
036     * @param reloadCriteriaOnChange Set this to <code>true</code> if in client-side, the change of the field of this parameter must lead to a reload of the search criteria
037     */
038    public AdditionalSearchServiceParameter(ServiceParameter<T> serviceParameter, boolean reloadCriteriaOnChange)
039    {
040        _serviceParameter = serviceParameter;
041        _reloadCriteriaOnChange = reloadCriteriaOnChange;
042    }
043    
044    /**
045     * Gets the additional service parameter
046     * @return the additional service parameter
047     */
048    public ServiceParameter<T> getParameter()
049    {
050        return _serviceParameter;
051    }
052    
053    /**
054     * Returns <code>true</code> if in client-side, the change of the field of this parameter must lead to a reload of the search criteria
055     * @return <code>true</code> if in client-side, the change of the field of this parameter must lead to a reload of the search criteria
056     */
057    public boolean reloadCriteriaOnChange()
058    {
059        return _reloadCriteriaOnChange;
060    }
061}