@Override
    public FeedOperation read() throws Exception {
        DocumentOperation documentOperation = reader.next();

        if (documentOperation == null) {
            stream.close();
            return FeedOperation.INVALID;
        }

        if (documentOperation instanceof DocumentUpdate) {
            return new DocumentUpdateFeedOperation((DocumentUpdate) documentOperation);
        } else if (documentOperation instanceof DocumentRemove) {
            return new RemoveFeedOperation((DocumentRemove)documentOperation);
        } else if (documentOperation instanceof DocumentPut) {
            return new DocumentFeedOperation((DocumentPut) documentOperation);
        } else {
            throw new IllegalArgumentException("Got unknown class from JSON reader: " + documentOperation.getClass().getName());
        }
    }
Facade between JsonReader and the FeedReader API.

The feed reader will take ownership of the input stream and close it when the
last parseable document has been read.

@author Steinar Knutsen
document/src/main/java/com/yahoo/document/json/JsonFeedReader.java