@Test public void readAllFromValidFileTest() throws IOException { File inputFile = new File("src/test/resources/many_clients.json"); try (JSONFileReader<Client> jsonFileReader = new JSONFileReader<>(inputFile, Client.class)) { List<Client> outputClients = jsonFileReader.getAll(); checkDeserializedClientsFromValidFile(outputClients); } }
public List<T> getAll() throws IOException { if (readingAsStream) { throw new IllegalStateException("Cannot use getAll after started reading as stream."); } else { CollectionType type = JSONMapper.Mapper.getTypeFactory().constructCollectionType(List.class, dataClass); return JSONMapper.Mapper.readValue(parser, type); } }
JSONFileReader implements Closeable { public List<T> getAll() throws IOException { if (readingAsStream) { throw new IllegalStateException("Cannot use getAll after started reading as stream."); } else { CollectionType type = JSONMapper.Mapper.getTypeFactory().constructCollectionType(List.class, dataClass); return JSONMapper.Mapper.readValue(parser, type); } } }
JSONFileReader implements Closeable { public List<T> getAll() throws IOException { if (readingAsStream) { throw new IllegalStateException("Cannot use getAll after started reading as stream."); } else { CollectionType type = JSONMapper.Mapper.getTypeFactory().constructCollectionType(List.class, dataClass); return JSONMapper.Mapper.readValue(parser, type); } } JSONFileReader(File file, Class<T> dataClass); }
JSONFileReader implements Closeable { public List<T> getAll() throws IOException { if (readingAsStream) { throw new IllegalStateException("Cannot use getAll after started reading as stream."); } else { CollectionType type = JSONMapper.Mapper.getTypeFactory().constructCollectionType(List.class, dataClass); return JSONMapper.Mapper.readValue(parser, type); } } JSONFileReader(File file, Class<T> dataClass); long getFileSize(); long getFilePosition(); void startStream(); T getNext(); List<T> getAll(); @Override void close(); }
JSONFileReader implements Closeable { public List<T> getAll() throws IOException { if (readingAsStream) { throw new IllegalStateException("Cannot use getAll after started reading as stream."); } else { CollectionType type = JSONMapper.Mapper.getTypeFactory().constructCollectionType(List.class, dataClass); return JSONMapper.Mapper.readValue(parser, type); } } JSONFileReader(File file, Class<T> dataClass); long getFileSize(); long getFilePosition(); void startStream(); T getNext(); List<T> getAll(); @Override void close();  }