private static <T extends Reply> T validateReply(Reply reply, Class<T> type) throws BucketStatsException {
        if (reply.hasErrors()) {
            throw new BucketStatsException(makeErrorMessage(reply));
        }
        if (!type.isInstance(reply)) {
            throw new BucketStatsException(String.format("Unexpected reply %s: '%s'", reply.getType(), reply.toString()));
        }
        return type.cast(reply);
    }
This class fetches bucket information from Vespa

@author bjorncs
vespaclient-java/src/main/java/com/yahoo/vespastat/BucketStatsRetriever.java