• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.data.customaudience;
18 
19 import android.adservices.common.AdData;
20 
21 import androidx.annotation.NonNull;
22 
23 import com.android.adservices.data.common.DBAdData;
24 
25 import org.json.JSONException;
26 import org.json.JSONObject;
27 
28 /** Strategy for doing optional feature-flagged parts of the ADData conversion */
29 public interface AdDataOptionalConversionStrategy {
30     /**
31      * Fills a part of the given {@link JSONObject} with the data from {@link DBAdData}.
32      *
33      * @param adData the {@link DBAdData} object to serialize
34      * @param jsonObject the target json serialization of the AdData object
35      */
toJson(DBAdData adData, JSONObject jsonObject)36     void toJson(DBAdData adData, JSONObject jsonObject) throws JSONException;
37 
38     /**
39      * Deserialize {@link DBAdData} from {@link JSONObject}.
40      *
41      * @param json the {@link JSONObject} object to dwserialize
42      * @param adDataBuilder the {@link DBAdData.Builder} to be filled from the json
43      */
fromJson(JSONObject json, DBAdData.Builder adDataBuilder)44     void fromJson(JSONObject json, DBAdData.Builder adDataBuilder) throws JSONException;
45 
46     /**
47      * Parse parcelable {@link AdData} to storage model {@link DBAdData}.
48      *
49      * @param parcelable the service model.
50      * @param adDataBuilder the target storage model to be filled
51      */
fromServiceObject(@onNull AdData parcelable, @NonNull DBAdData.Builder adDataBuilder)52     void fromServiceObject(@NonNull AdData parcelable, @NonNull DBAdData.Builder adDataBuilder);
53 }
54