001package com.mrivanplays.annotationconfig.core.resolver;
002
003import com.mrivanplays.annotationconfig.core.resolver.options.CustomOptions;
004import com.mrivanplays.annotationconfig.core.resolver.settings.LoadSettings;
005import java.io.IOException;
006import java.io.Reader;
007import java.util.Map;
008
009/**
010 * Represents a reader of values from a {@link Reader} to a {@link Map} of primitive options (using
011 * {@link String} as a key). When it is implemented, it should implement 1 of the 2 methods,
012 * otherwise a {@link IllegalArgumentException} is thrown if none of the methods is implemented.
013 *
014 * @author MrIvanPlays
015 * @since 2.0.0
016 */
017public interface ValueReader {
018
019  /**
020   * Should read the specified reader to a Map.
021   *
022   * @param reader the reader we need read
023   * @return the values read, represented as a map, or empty map if no values have been read
024   * @throws IOException if an io occurs
025   */
026  default Map<String, Object> read(Reader reader) throws IOException {
027    throw new IllegalArgumentException("ValueReader not implemented");
028  }
029
030  /**
031   * Should read the specified reader to a Map. Can use the specified {@link CustomOptions} to
032   * manipulate the output of this method, or the ways the reader is parsed to the needed output.
033   *
034   * @param reader the reader we need read
035   * @param customOptions the read options
036   * @return the values read, represented as a map, or empty map if no values have been read
037   * @throws IOException if an io occurs
038   */
039  default Map<String, Object> read(Reader reader, CustomOptions customOptions) throws IOException {
040    return read(reader);
041  }
042
043  /**
044   * Should read the specified reader to a Map. Can use the specified {@link CustomOptions} and
045   * {@link LoadSettings} to manipulate the output of this method, or the ways the reader is parsed
046   * to the needed output.
047   *
048   * @param reader the reader we need read
049   * @param customOptions the read options
050   * @param loadSettings the load settings
051   * @return the values read, represented as a map, or empty map if no values have been read
052   * @throws IOException if an io occurs
053   */
054  default Map<String, Object> read(
055      Reader reader, CustomOptions customOptions, LoadSettings loadSettings) throws IOException {
056    return read(reader, customOptions);
057  }
058}