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 java.util.Map; 019import java.util.Optional; 020 021import org.ametys.cms.search.SearchField; 022import org.ametys.runtime.i18n.I18nizableText; 023 024/** 025 * A potential facet proposed to the creator of an instance of search service. 026 */ 027public interface FacetDefinition 028{ 029 /** 030 * Gets the id of the facet. It must be unique across all facet definitions 031 * @return the unique id of the facet 032 */ 033 String getId(); 034 035 /** 036 * Gets the label of the facet. 037 * @return the label of the facet. 038 */ 039 I18nizableText getLabel(); 040 041 /** 042 * Gets the search field of this facet 043 * @return the search field of this facet 044 */ 045 SearchField getSearchField(); 046 047 /** 048 * Gets the label of a facet value 049 * @param value the facet value 050 * @param contextualParameters the contextual parameters 051 * @return the label of a facet value 052 */ 053 Optional<I18nizableText> getFacetLabel(String value, Map<String, Object> contextualParameters); 054 055 /** 056 * Gets the ({@link Returnable}) the facet belongs to. 057 * @return the ({@link Returnable}) the facet belongs to. 058 */ 059 Optional<Returnable> getReturnable(); 060}