Home | History | Annotate | Download | only in config
      1 /*
      2  * Copyright (C) 2016 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.config;
     17 
     18 import com.android.tradefed.util.MultiMap;
     19 
     20 import com.google.common.annotations.VisibleForTesting;
     21 
     22 import java.util.ArrayList;
     23 import java.util.List;
     24 
     25 /**
     26  * Configuration Object that describes some aspect of the configuration itself. Like a membership
     27  * test-suite-tag. This class cannot receive option values via command line. Only directly in the
     28  * xml.
     29  */
     30 @OptionClass(alias = "config-descriptor")
     31 public class ConfigurationDescriptor {
     32 
     33     @Option(name = "test-suite-tag", description = "A membership tag to suite. Can be repeated.")
     34     private List<String> mSuiteTags = new ArrayList<>();
     35 
     36     @Option(name = "metadata", description = "Metadata associated with this configuration, can be "
     37             + "free formed key value pairs, and a key may be associated with multiple values.")
     38     private MultiMap<String, String> mMetaData = new MultiMap<>();
     39 
     40     @Option(
     41         name = "not-shardable",
     42         description =
     43                 "A metadata that allows a suite configuration to specify that it cannot be "
     44                         + "sharded. Not because it doesn't support it but because it doesn't make "
     45                         + "sense."
     46     )
     47     private boolean mNotShardable = false;
     48 
     49     /** Returns the list of suite tags the test is part of. */
     50     public List<String> getSuiteTags() {
     51         return mSuiteTags;
     52     }
     53 
     54     /** Sets the list of suite tags the test is part of. */
     55     public void setSuiteTags(List<String> suiteTags) {
     56         mSuiteTags = suiteTags;
     57     }
     58 
     59     /** Retrieves all configured metadata */
     60     public MultiMap<String, String> getAllMetaData() {
     61         return mMetaData;
     62     }
     63 
     64     /** Get the named metadata entries */
     65     public List<String> getMetaData(String name) {
     66         return mMetaData.get(name);
     67     }
     68 
     69     @VisibleForTesting
     70     public void setMetaData(MultiMap<String, String> metadata) {
     71         mMetaData = metadata;
     72     }
     73 
     74     /** Returns if the configuration is shardable or not as part of a suite */
     75     public boolean isNotShardable() {
     76         return mNotShardable;
     77     }
     78 }
     79