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.tradefed.build; 17 18 19 /** 20 * A {@link IBuildProvider} that returns an already constructed {@link IBuildInfo}. 21 */ 22 public class ExistingBuildProvider implements IBuildProvider { 23 24 private final IBuildInfo mBuildInfo; 25 private final IBuildProvider mParentProvider; 26 private boolean mBuildMarkedNotTested = false; 27 28 /** 29 * Creates a {@link ExistingBuildProvider}. 30 * 31 * @param buildInfo the existing build to provide 32 * @param parentProvider the original {@link IBuildProvider} that created the {@link IBuildInfo} 33 * Needed to pass along {@link IBuildProvider#buildNotTested(IBuildInfo)} events. 34 */ 35 public ExistingBuildProvider(IBuildInfo buildInfo, IBuildProvider parentProvider) { 36 mBuildInfo = buildInfo; 37 mParentProvider = parentProvider; 38 } 39 40 /** 41 * {@inheritDoc} 42 */ 43 @Override 44 public IBuildInfo getBuild() throws BuildRetrievalError { 45 return mBuildInfo; 46 } 47 48 /** 49 * {@inheritDoc} 50 */ 51 @Override 52 public void buildNotTested(IBuildInfo info) { 53 if (!mBuildMarkedNotTested) { 54 mBuildMarkedNotTested = true; 55 mParentProvider.buildNotTested(info); 56 } 57 } 58 59 /** 60 * {@inheritDoc} 61 */ 62 @Override 63 public void cleanUp(IBuildInfo info) { 64 mParentProvider.cleanUp(info); 65 } 66 } 67