001/*
002 * This file is part of the JDrupes non-blocking HTTP Codec
003 * Copyright (C) 2016, 2017  Michael N. Lipp
004 *
005 * This program is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Lesser General Public License as published
007 * by the Free Software Foundation; either version 3 of the License, or 
008 * (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful, but 
011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
013 * License for more details.
014 *
015 * You should have received a copy of the GNU Lesser General Public License along 
016 * with this program; if not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jdrupes.httpcodec.types;
020
021import java.util.function.BiConsumer;
022import java.util.function.Supplier;
023
024/**
025 * Implemented by converters that convert header fields with a list of values.
026 * 
027 * Minimal restrictions are imposed on the type used as container for the 
028 * values. It must be {@link Iterable} to provide read access. A supplier
029 * and a function for appending values provide the required write access.
030 * 
031 * @param <T> the container for the values
032 * @param <V> the type of the values
033 */
034public interface MultiValueConverter<T extends Iterable<V>, V>
035        extends Converter<T> {
036
037        /**
038         * Returns the container supplier
039         * 
040         * @return the container supplier
041         */
042        Supplier<T> containerSupplier();
043
044        /**
045         * Returns the value adder
046         * 
047         * @return the value adder
048         */
049        BiConsumer<T, V> valueAdder();
050
051        /**
052         * Returns the value converter.
053         * 
054         * @return the value converter
055         */
056        Converter<V> valueConverter();
057
058        /**
059         * Return whether values should be converted to separate
060         * header fields in {@link Converter#asFieldValue(Object)}.
061         * 
062         * @return the value
063         */
064        boolean separateValues();
065
066}