code: public static RetryPolicy nAttempts(final int n) {
      return new RetryPolicy() {
        @Override public Instance createInstance() {
          return new Instance() {
  
            private int count = 0;
  
            @Override public boolean shouldRetry(GenomicsRequest genomicsRequest, IOException e) {
              return count++ < n;
            }
          };
        }
      };
    }
docs: Retry requests up to {@code n} times.