1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.tradefed.suite.checker;
17 
18 /** Contains the result of a {@link ISystemStatusChecker} execution. */
19 public class StatusCheckerResult {
20 
21     public enum CheckStatus {
22         /** status check was successful */
23         SUCCESS,
24         /** status check did not succeed. An error message might be available (optional). */
25         FAILED,
26     }
27 
28     private CheckStatus mCheckStatus = CheckStatus.FAILED;
29     private String mErrorMessage = null;
30     private boolean mBugreportNeeded = false;
31 
32     /** Create a {@link StatusCheckerResult} with the default {@link CheckStatus#FAILED} status. */
StatusCheckerResult()33     public StatusCheckerResult() {}
34 
35     /**
36      * Create a {@link StatusCheckerResult} with the given status.
37      *
38      * @param status the {@link CheckStatus}
39      */
StatusCheckerResult(CheckStatus status)40     public StatusCheckerResult(CheckStatus status) {
41         mCheckStatus = status;
42     }
43 
44     /** Returns the {@link CheckStatus} of the checker. */
getStatus()45     public CheckStatus getStatus() {
46         return mCheckStatus;
47     }
48 
49     /** Sets the {@link CheckStatus} of the checker. */
setStatus(CheckStatus status)50     public void setStatus(CheckStatus status) {
51         mCheckStatus = status;
52     }
53 
54     /**
55      * Returns the error message associated with a failure. Can be null even in case of failures.
56      */
getErrorMessage()57     public String getErrorMessage() {
58         return mErrorMessage;
59     }
60 
61     /** Sets the error message associated with a failure. */
setErrorMessage(String message)62     public void setErrorMessage(String message) {
63         mErrorMessage = message;
64     }
65 
66     /** Returns whether or not a bugreport is needed in case of checker failure. */
isBugreportNeeded()67     public boolean isBugreportNeeded() {
68         return mBugreportNeeded;
69     }
70 
71     /** Sets whether or not a bugreport is needed in case of checker failure. */
setBugreportNeeded(boolean need)72     public void setBugreportNeeded(boolean need) {
73         mBugreportNeeded = need;
74     }
75 }
76