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