1 /* 2 * Copyright (C) 2022 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.adservices.service.stats; 18 19 import android.annotation.NonNull; 20 21 import java.util.Objects; 22 23 /** Class for UI Stats. */ 24 public class UIStats { 25 private int mCode; 26 private int mRegion; 27 private int mAction; 28 private int mDefaultConsent; 29 private int mDefaultAdIdState; 30 private int mPrivacySandboxFeatureType; 31 UIStats()32 public UIStats() {} 33 34 @Override equals(Object obj)35 public boolean equals(Object obj) { 36 if (!(obj instanceof UIStats)) { 37 return false; 38 } 39 UIStats uiStats = (UIStats) obj; 40 return mCode == uiStats.getCode() 41 && mRegion == uiStats.getRegion() 42 && mAction == uiStats.getAction() 43 && mDefaultConsent == uiStats.getDefaultConsent() 44 && mDefaultAdIdState == uiStats.getDefaultAdIdState() 45 && mPrivacySandboxFeatureType == uiStats.getPrivacySandboxFeatureType(); 46 } 47 48 @Override hashCode()49 public int hashCode() { 50 return Objects.hash( 51 mCode, 52 mRegion, 53 mAction, 54 mDefaultConsent, 55 mDefaultAdIdState, 56 mPrivacySandboxFeatureType); 57 } 58 59 @NonNull getCode()60 public int getCode() { 61 return mCode; 62 } 63 64 @NonNull getRegion()65 public int getRegion() { 66 return mRegion; 67 } 68 69 @NonNull getAction()70 public int getAction() { 71 return mAction; 72 } 73 74 @NonNull getDefaultConsent()75 public int getDefaultConsent() { 76 return mDefaultConsent; 77 } 78 79 @NonNull getDefaultAdIdState()80 public int getDefaultAdIdState() { 81 return mDefaultAdIdState; 82 } 83 84 @NonNull getPrivacySandboxFeatureType()85 public int getPrivacySandboxFeatureType() { 86 return mPrivacySandboxFeatureType; 87 } 88 setRegion(int region)89 public void setRegion(int region) { 90 mRegion = region; 91 } 92 setAction(int action)93 public void setAction(int action) { 94 mAction = action; 95 } 96 setDefaultConsent(int defaultConsent)97 public void setDefaultConsent(int defaultConsent) { 98 mDefaultConsent = defaultConsent; 99 } 100 setDefaultAdIdState(int defaultAdIdState)101 public void setDefaultAdIdState(int defaultAdIdState) { 102 mDefaultAdIdState = defaultAdIdState; 103 } 104 105 @Override toString()106 public String toString() { 107 return "UIStats{" 108 + "mCode=" 109 + mCode 110 + ", mRegion=" 111 + mRegion 112 + ", mAction=" 113 + mAction 114 + ", mDefaultConsent=" 115 + mDefaultConsent 116 + ", mDefaultAdIdState=" 117 + mDefaultAdIdState 118 + ", mPrivacySandboxFeatureType" 119 + mPrivacySandboxFeatureType 120 + '}'; 121 } 122 123 /** Builder for {@link UIStats}. */ 124 public static final class Builder { 125 private final UIStats mBuilding; 126 Builder()127 public Builder() { 128 mBuilding = new UIStats(); 129 } 130 131 /** See {@link UIStats#getCode()} . */ setCode(int code)132 public @NonNull UIStats.Builder setCode(int code) { 133 mBuilding.mCode = code; 134 return this; 135 } 136 137 /** See {@link UIStats#getRegion()} . */ setRegion(int region)138 public @NonNull UIStats.Builder setRegion(int region) { 139 mBuilding.mRegion = region; 140 return this; 141 } 142 143 /** See {@link UIStats#getAction()} . */ setAction(int action)144 public @NonNull UIStats.Builder setAction(int action) { 145 mBuilding.mAction = action; 146 return this; 147 } 148 149 /** See {@link UIStats#getAction()} . */ setDefaultConsent(int defaultConsent)150 public @NonNull UIStats.Builder setDefaultConsent(int defaultConsent) { 151 mBuilding.mDefaultConsent = defaultConsent; 152 return this; 153 } 154 155 /** See {@link UIStats#getAction()} . */ setDefaultAdIdState(int defaultAdIdState)156 public @NonNull UIStats.Builder setDefaultAdIdState(int defaultAdIdState) { 157 mBuilding.mDefaultAdIdState = defaultAdIdState; 158 return this; 159 } 160 161 /** See {@link UIStats#getAction()} . */ setPrivacySandboxFeatureType( int privacySandboxFeatureType)162 public @NonNull UIStats.Builder setPrivacySandboxFeatureType( 163 int privacySandboxFeatureType) { 164 mBuilding.mPrivacySandboxFeatureType = privacySandboxFeatureType; 165 return this; 166 } 167 /** Build the {@link UIStats}. */ build()168 public @NonNull UIStats build() { 169 return mBuilding; 170 } 171 } 172 } 173