001/*
002 *  Copyright 2019 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.List;
019import java.util.Map;
020
021import org.ametys.runtime.i18n.I18nizableText;
022import org.ametys.runtime.model.Enumerator;
023
024/**
025 * Represents an {@link Enumerator} with restricted entries, used by criterion definitions
026 * @param <T> Type of the values
027 */
028public interface RestrictedEnumerator<T> extends Enumerator<T>
029{
030    /**
031     * Gets the {@link RestrictedValues} object
032     * <br>The implementation must decide whether or not the given objects must be validated among {@link #getEntries() all values}, if they must be converted, etc.
033     * @param objs The desired objects
034     * @return the {@link RestrictedValues}
035     * @throws Exception if an error occurs.
036     */
037    RestrictedValues<T> getRestrictedEntriesFor(List<T> objs)  throws Exception;
038    
039    /**
040     * Represents a subset of values (some 'restricted' values) of a given {@link RestrictedEnumerator}.
041     *  @param <T> Type of the restricted values
042     */
043    interface RestrictedValues<T>
044    {
045        Map<T, I18nizableText> values() throws Exception;
046    }
047}
048