Home | History | Annotate | Download | only in experiments
      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.contactsbind.experiments;
     17 
     18 import java.util.HashMap;
     19 import java.util.Map;
     20 
     21 /**
     22  * Provides getters for experiment flags.
     23  * This stub class is designed to be overwritten by an overlay.
     24  */
     25 public final class Flags {
     26 
     27     private static Flags sInstance;
     28 
     29     private Map<String, Object> mMap;
     30 
     31     public static Flags getInstance() {
     32         if (sInstance == null) {
     33             sInstance = new Flags();
     34         }
     35         return sInstance;
     36     }
     37 
     38     private Flags() {
     39         mMap = new HashMap<>();
     40     }
     41 
     42     public boolean getBoolean(String flagName) {
     43         return mMap.containsKey(flagName) ? (boolean) mMap.get(flagName) : false;
     44     }
     45 
     46     public int getInteger(String flagName) {
     47         return mMap.containsKey(flagName) ? ((Integer) mMap.get(flagName)).intValue() : 0;
     48     }
     49 }
     50