1 /* 2 * Copyright (C) 2021 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 com.android.bedstead.nene.utils; 18 19 import java.util.Collections; 20 import java.util.Set; 21 import java.util.concurrent.ConcurrentHashMap; 22 23 /** 24 * Collection of {@link String} values which can change behaviour of APIs. 25 */ 26 public final class Tags { 27 28 public static final String USES_DEVICESTATE = "uses_devicestate"; 29 public static final String USES_NOTIFICATIONS = "uses_notifications"; 30 public static final String INSTANT_APP = "instant_app"; 31 Tags()32 private Tags() { 33 34 } 35 36 private static final Set<String> sTags = Collections.newSetFromMap(new ConcurrentHashMap<>()); 37 38 /** 39 * {@code true} if the tag has been added. 40 */ hasTag(String tag)41 public static boolean hasTag(String tag) { 42 return sTags.contains(tag); 43 } 44 45 /** 46 * Clear all added tags. 47 */ clearTags()48 public static void clearTags() { 49 sTags.clear(); 50 } 51 52 /** 53 * Add a tag. 54 */ addTag(String tag)55 public static void addTag(String tag) { 56 sTags.add(tag); 57 } 58 } 59