Line data Source code
1 : // Copyright (C) 2017 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.extensions.api.config; 16 : 17 : import com.google.errorprone.annotations.FormatMethod; 18 : import java.util.List; 19 : import java.util.Objects; 20 : 21 3 : public class ConsistencyCheckInfo { 22 : public CheckAccountsResultInfo checkAccountsResult; 23 : public CheckAccountExternalIdsResultInfo checkAccountExternalIdsResult; 24 : public CheckGroupsResultInfo checkGroupsResult; 25 : 26 : public static class CheckAccountsResultInfo { 27 : public List<ConsistencyProblemInfo> problems; 28 : 29 1 : public CheckAccountsResultInfo(List<ConsistencyProblemInfo> problems) { 30 1 : this.problems = problems; 31 1 : } 32 : } 33 : 34 : public static class CheckAccountExternalIdsResultInfo { 35 : public List<ConsistencyProblemInfo> problems; 36 : 37 1 : public CheckAccountExternalIdsResultInfo(List<ConsistencyProblemInfo> problems) { 38 1 : this.problems = problems; 39 1 : } 40 : } 41 : 42 : public static class CheckGroupsResultInfo { 43 : public List<ConsistencyProblemInfo> problems; 44 : 45 1 : public CheckGroupsResultInfo(List<ConsistencyProblemInfo> problems) { 46 1 : this.problems = problems; 47 1 : } 48 : } 49 : 50 : public static class ConsistencyProblemInfo { 51 4 : public enum Status { 52 4 : FATAL, 53 4 : ERROR, 54 4 : WARNING, 55 : } 56 : 57 : public final Status status; 58 : public final String message; 59 : 60 4 : public ConsistencyProblemInfo(Status status, String message) { 61 4 : this.status = status; 62 4 : this.message = message; 63 4 : } 64 : 65 : @Override 66 : public boolean equals(Object o) { 67 3 : if (o instanceof ConsistencyProblemInfo) { 68 3 : ConsistencyProblemInfo other = ((ConsistencyProblemInfo) o); 69 3 : return Objects.equals(status, other.status) && Objects.equals(message, other.message); 70 : } 71 0 : return false; 72 : } 73 : 74 : @Override 75 : public int hashCode() { 76 2 : return Objects.hash(status, message); 77 : } 78 : 79 : @Override 80 : public String toString() { 81 0 : return status.name() + ": " + message; 82 : } 83 : 84 : @FormatMethod 85 : public static ConsistencyProblemInfo warning(String fmt, Object... args) { 86 2 : return new ConsistencyProblemInfo(Status.WARNING, String.format(fmt, args)); 87 : } 88 : 89 : @FormatMethod 90 : public static ConsistencyProblemInfo error(String fmt, Object... args) { 91 1 : return new ConsistencyProblemInfo(Status.ERROR, String.format(fmt, args)); 92 : } 93 : } 94 : }