1 /*
2  * Copyright (C) 2011 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.cts.tradefed.result;
17 
18 /**
19  * An enum of possible test statuses.
20  */
21 public enum CtsTestStatus {
22     PASS("pass"),
23     FAIL("fail"),
24     NOT_EXECUTED("notExecuted");
25 
26     private String mValue;
27 
CtsTestStatus(String storedValue)28     CtsTestStatus(String storedValue) {
29         mValue = storedValue;
30     }
31 
32     /**
33      * Get the String representation of this test status that should be stored in
34      * xml
35      * @return
36      */
getValue()37     String getValue() {
38        return mValue;
39     }
40 
41     /**
42      * Find the {@link CtsTestStatus} corresponding to given string value
43      * <p/>
44      * Performs a case insensitive search
45      *
46      * @param value
47      * @return the CtsTestStatus or <code>null</code> if it could not be found
48      */
getStatus(String value)49     static CtsTestStatus getStatus(String  value) {
50         for (CtsTestStatus status : CtsTestStatus.values()) {
51             if (value.compareToIgnoreCase(status.getValue()) == 0) {
52                 return status;
53             }
54         }
55         return null;
56     }
57 }
58