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 com.android.adservices.service.signals.updateprocessors; 18 19 import androidx.annotation.NonNull; 20 21 import com.android.adservices.data.signals.DBProtectedSignal; 22 23 import java.nio.ByteBuffer; 24 import java.util.ArrayList; 25 import java.util.HashSet; 26 import java.util.List; 27 import java.util.Set; 28 29 /** The output of an UpdateProcessor strategy */ 30 public class UpdateOutput { 31 private final List<DBProtectedSignal.Builder> mToAdd = new ArrayList<>(); 32 private final List<DBProtectedSignal> mToRemove = new ArrayList<>(); 33 private final Set<ByteBuffer> mKeysTouched = new HashSet<>(); 34 private UpdateEncoderEvent mUpdateEncoderEvent; 35 36 /** The list of signals from the JSON to add. */ getToAdd()37 public List<DBProtectedSignal.Builder> getToAdd() { 38 return mToAdd; 39 } 40 41 /** The list of signals from the JSON to remove. */ getToRemove()42 public List<DBProtectedSignal> getToRemove() { 43 return mToRemove; 44 } 45 46 /** 47 * The list of keys this process modified or could have modified. It is important that 48 * processors add keys that they considered, but did not take action on, here to prevent 49 * conflicts with other processors. 50 */ getKeysTouched()51 public Set<ByteBuffer> getKeysTouched() { 52 return mKeysTouched; 53 } 54 55 /** Sets the {@link UpdateEncoderEvent} for the UpdateOutput, there can be only one */ setUpdateEncoderEvent(@onNull UpdateEncoderEvent event)56 public void setUpdateEncoderEvent(@NonNull UpdateEncoderEvent event) { 57 mUpdateEncoderEvent = event; 58 } 59 60 /** 61 * @return an {@link UpdateEncoderEvent} for the UpdateOutput, there can be only one 62 */ getUpdateEncoderEvent()63 public UpdateEncoderEvent getUpdateEncoderEvent() { 64 return mUpdateEncoderEvent; 65 } 66 } 67