@Test public void readAsStreamWithoutStartingStreamTest() { File inputFile = new File("src/test/resources/many_clients.json"); assertThrows(IllegalStateException.class, () -> { try (JSONFileReader<Client> clientFileReader = new JSONFileReader<>(inputFile, Client.class)) { clientFileReader.getNext(); } }); }
public T getNext() throws IOException { if (readingAsStream) { JsonToken token = parser.nextToken(); if (token == JsonToken.END_ARRAY || token == null) { return null; } return JSONMapper.Mapper.readValue(parser, dataClass); } else { throw new IllegalStateException("Must have called startStream before calling getNext."); } }
JSONFileReader implements Closeable { public T getNext() throws IOException { if (readingAsStream) { JsonToken token = parser.nextToken(); if (token == JsonToken.END_ARRAY || token == null) { return null; } return JSONMapper.Mapper.readValue(parser, dataClass); } else { throw new IllegalStateException("Must have called startStream before calling getNext."); } } }
JSONFileReader implements Closeable { public T getNext() throws IOException { if (readingAsStream) { JsonToken token = parser.nextToken(); if (token == JsonToken.END_ARRAY || token == null) { return null; } return JSONMapper.Mapper.readValue(parser, dataClass); } else { throw new IllegalStateException("Must have called startStream before calling getNext."); } } JSONFileReader(File file, Class<T> dataClass); }
JSONFileReader implements Closeable { public T getNext() throws IOException { if (readingAsStream) { JsonToken token = parser.nextToken(); if (token == JsonToken.END_ARRAY || token == null) { return null; } return JSONMapper.Mapper.readValue(parser, dataClass); } else { throw new IllegalStateException("Must have called startStream before calling getNext."); } } JSONFileReader(File file, Class<T> dataClass); long getFileSize(); long getFilePosition(); void startStream(); T getNext(); List<T> getAll(); @Override void close(); }
JSONFileReader implements Closeable { public T getNext() throws IOException { if (readingAsStream) { JsonToken token = parser.nextToken(); if (token == JsonToken.END_ARRAY || token == null) { return null; } return JSONMapper.Mapper.readValue(parser, dataClass); } else { throw new IllegalStateException("Must have called startStream before calling getNext."); } } JSONFileReader(File file, Class<T> dataClass); long getFileSize(); long getFilePosition(); void startStream(); T getNext(); List<T> getAll(); @Override void close();  }