You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GsonAzureRepo.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2022 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.alm.client.azure;
  21. import com.google.gson.annotations.SerializedName;
  22. import java.util.regex.Pattern;
  23. public class GsonAzureRepo {
  24. private static final String BRANCH_FULL_NAME_PREFIX = "refs/heads/";
  25. @SerializedName("id")
  26. private String id;
  27. @SerializedName("name")
  28. private String name;
  29. @SerializedName("url")
  30. private String url;
  31. @SerializedName("project")
  32. private GsonAzureProject project;
  33. @SerializedName("defaultBranch")
  34. private String defaultBranchFullName;
  35. public GsonAzureRepo() {
  36. // http://stackoverflow.com/a/18645370/229031
  37. }
  38. public GsonAzureRepo(String id, String name, String url, GsonAzureProject project, String defaultBranchFullName) {
  39. this.id = id;
  40. this.name = name;
  41. this.url = url;
  42. this.project = project;
  43. this.defaultBranchFullName = defaultBranchFullName;
  44. }
  45. public String getId() {
  46. return id;
  47. }
  48. public String getName() {
  49. return name;
  50. }
  51. public String getUrl() {
  52. return url;
  53. }
  54. public GsonAzureProject getProject() {
  55. return project;
  56. }
  57. public String getDefaultBranchName() {
  58. if (defaultBranchFullName == null || defaultBranchFullName.equals("")) {
  59. return null;
  60. }
  61. return Pattern
  62. .compile(Pattern.quote(BRANCH_FULL_NAME_PREFIX), Pattern.CASE_INSENSITIVE)
  63. .matcher(defaultBranchFullName)
  64. .replaceAll("");
  65. }
  66. }