<commit_before>// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.gerrit.client.diff;

import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.info.FileInfo;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class DiffApi {
  public enum IgnoreWhitespace {
    NONE, TRAILING, CHANGED, ALL
  }

  public static void list(int id, String base, String revision,
      AsyncCallback<NativeMap<FileInfo>> cb) {
    RestApi api = ChangeApi.revision(id, revision).view("files");
    if (base != null) {
      api.addParameter("base", base);
    }
    api.get(NativeMap.copyKeysIntoChildren("path", cb));
  }

  public static void list(PatchSet.Id id, PatchSet.Id base,
      AsyncCallback<NativeMap<FileInfo>> cb) {
    RestApi api = ChangeApi.revision(id).view("files");
    if (base != null) {
      api.addParameter("base", base.get());
    }
    api.get(NativeMap.copyKeysIntoChildren("path", cb));
  }

  public static DiffApi diff(PatchSet.Id id, String path) {
    return new DiffApi(ChangeApi.revision(id)
        .view("files").id(path)
        .view("diff"));
  }

  private final RestApi call;

  private DiffApi(RestApi call) {
    this.call = call;
  }

  public DiffApi base(PatchSet.Id id) {
    if (id != null) {
      call.addParameter("base", id.get());
    }
    return this;
  }

  public DiffApi webLinksOnly() {
    call.addParameterTrue("weblinks-only");
    return this;
  }

  public DiffApi ignoreWhitespace(DiffPreferencesInfo.Whitespace w) {
    if (w != null && w != Whitespace.IGNORE_ALL) {
      call.addParameter("whitespace", w);
    }
    return this;
  }
<commit_msg>DiffApi: Remove unused IgnoreWhitespace enum<commit_after>// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.gerrit.client.diff;

import static com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace.IGNORE_ALL;

import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.info.FileInfo;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class DiffApi {
  public static void list(int id, String base, String revision,
      AsyncCallback<NativeMap<FileInfo>> cb) {
    RestApi api = ChangeApi.revision(id, revision).view("files");
    if (base != null) {
      api.addParameter("base", base);
    }
    api.get(NativeMap.copyKeysIntoChildren("path", cb));
  }

  public static void list(PatchSet.Id id, PatchSet.Id base,
      AsyncCallback<NativeMap<FileInfo>> cb) {
    RestApi api = ChangeApi.revision(id).view("files");
    if (base != null) {
      api.addParameter("base", base.get());
    }
    api.get(NativeMap.copyKeysIntoChildren("path", cb));
  }

  public static DiffApi diff(PatchSet.Id id, String path) {
    return new DiffApi(ChangeApi.revision(id)
        .view("files").id(path)
        .view("diff"));
  }

  private final RestApi call;

  private DiffApi(RestApi call) {
    this.call = call;
  }

  public DiffApi base(PatchSet.Id id) {
    if (id != null) {
      call.addParameter("base", id.get());
    }
    return this;
  }

  public DiffApi webLinksOnly() {
    call.addParameterTrue("weblinks-only");
    return this;
  }

  public DiffApi ignoreWhitespace(DiffPreferencesInfo.Whitespace w) {
    if (w != null && w != IGNORE_ALL) {
      call.addParameter("whitespace", w);
    }
    return this;
  }

{'fraction_non_alphanumeric': 0.12035541195476575, 'fraction_numerical': 0.0032310177705977385, 'mean_word_length': 3.6594543744120416, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4941017', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1494, 'n_words': 412}