1 /* 2 * Copyright (C) 2017 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.util; 17 18 /** 19 * Interface that describes a Tradefed object that can be disabled. A disabled object will be 20 * skipped and not called at all. 21 */ 22 public interface IDisableable { 23 24 /** Returns True if entire object disabled (skip both setup and teardown). False otherwise. */ isDisabled()25 public default boolean isDisabled() { 26 return false; 27 } 28 29 /** Returns True if just teardown should be skipped. False otherwise. */ isTearDownDisabled()30 public default boolean isTearDownDisabled() { 31 return false; 32 } 33 34 /** 35 * Sets whether the object should be disabled. Disabled means that both setup and teardown steps 36 * should be skipped. Can be use to make an object disabled by default in the default 37 * constructor. 38 * 39 * @param isDisabled the state the object should be put in. 40 */ setDisable(boolean isDisabled)41 public default void setDisable(boolean isDisabled) { 42 // TODO: Remove the default empty implementation 43 } 44 45 /** 46 * Sets whether the teardown step in the object should be skipped. Setup step is still done. 47 * 48 * @param isDisabled the state the object should be put in. 49 */ setDisableTearDown(boolean isDisabled)50 public default void setDisableTearDown(boolean isDisabled) { 51 // Empty implementation to avoid having to implement everywhere. 52 } 53 } 54