1 /* 2 * Copyright (C) 2023 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 17 package android.flags; 18 19 import android.annotation.NonNull; 20 21 abstract class BooleanFlagBase implements Flag<Boolean> { 22 23 private final String mNamespace; 24 private final String mName; 25 private String mLabel; 26 private String mDescription; 27 private String mCategoryName; 28 29 /** 30 * @param namespace A namespace for this flag. See {@link android.provider.DeviceConfig}. 31 * @param name A name for this flag. 32 */ BooleanFlagBase(String namespace, String name)33 BooleanFlagBase(String namespace, String name) { 34 mNamespace = namespace; 35 mName = name; 36 mLabel = name; 37 } 38 getDefault()39 public abstract Boolean getDefault(); 40 41 @Override 42 @NonNull getNamespace()43 public String getNamespace() { 44 return mNamespace; 45 } 46 47 @Override 48 @NonNull getName()49 public String getName() { 50 return mName; 51 } 52 53 @Override defineMetaData(String label, String description, String categoryName)54 public BooleanFlagBase defineMetaData(String label, String description, String categoryName) { 55 mLabel = label; 56 mDescription = description; 57 mCategoryName = categoryName; 58 return this; 59 } 60 61 @Override 62 @NonNull getLabel()63 public String getLabel() { 64 return mLabel; 65 } 66 67 @Override getDescription()68 public String getDescription() { 69 return mDescription; 70 } 71 72 @Override getCategoryName()73 public String getCategoryName() { 74 return mCategoryName; 75 } 76 77 @Override 78 @NonNull toString()79 public String toString() { 80 return getNamespace() + "." + getName() + "[" + getDefault() + "]"; 81 } 82 } 83