001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005
006package gov.nist.secauto.metaschema.databind.model.info;
007
008import java.io.IOException;
009import java.util.List;
010import java.util.Map;
011
012import edu.umd.cs.findbugs.annotations.NonNull;
013import edu.umd.cs.findbugs.annotations.Nullable;
014
015public interface IModelInstanceReadHandler<ITEM> {
016  @Nullable
017  default ITEM readSingleton() throws IOException {
018    return readItem();
019  }
020
021  @NonNull
022  List<ITEM> readList() throws IOException;
023
024  @NonNull
025  Map<String, ITEM> readMap() throws IOException;
026
027  /**
028   * Read the next item in the collection of items represented by the instance.
029   *
030   * @return the Java object representing the item, or {@code null} if no items
031   *         remain to be read
032   * @throws IOException
033   *           if an error occurred while parsing the input
034   */
035  @Nullable
036  ITEM readItem() throws IOException;
037
038  @Nullable
039  String getJsonKeyFlagName();
040}