• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
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 package com.google.android.libraries.mobiledatadownload;
17 
18 import android.accounts.Account;
19 import com.google.auto.value.AutoValue;
20 import com.google.common.base.Optional;
21 import com.google.mobiledatadownload.DownloadConfigProto.DataFileGroup;
22 import javax.annotation.concurrent.Immutable;
23 
24 /**
25  * Request to remove file groups from MDD that match given filters.
26  *
27  * <p>With the exception of account filtering (see below), only the filters provided will be applied
28  * to file groups in MDD. That is, a file groups will be removed if and only if it matches all
29  * <em>provided</em> filters. See each filter setter description for more details on how filtering
30  * will be performed.
31  *
32  * <p>NOTE: Account filtering is a considered special case as filtering is performed <b>both</b>
33  * when account is provided and when it is absent. see {@link Builder#setAccountOptional} for more
34  * details on account filtering.
35  */
36 @AutoValue
37 @Immutable
38 public abstract class RemoveFileGroupsByFilterRequest {
RemoveFileGroupsByFilterRequest()39   RemoveFileGroupsByFilterRequest() {}
40 
accountOptional()41   public abstract Optional<Account> accountOptional();
42 
newBuilder()43   public static Builder newBuilder() {
44     return new AutoValue_RemoveFileGroupsByFilterRequest.Builder();
45   }
46 
47   /** Builder for {@link RemoveFileGroupsByFilterRequest}. */
48   @AutoValue.Builder
49   public abstract static class Builder {
Builder()50     Builder() {}
51 
52     /**
53      * Sets the {@link Account} that must match filtered {@link DataFileGroup}s.
54      *
55      * <p>Similar to other MDD APIs, file groups that are <em>account-dependent</em> must have that
56      * account provided in order to perform a requested operation; file groups that are
57      * <em>account-independent</em> must have no account provided in order to perform a requested
58      * operation.
59      *
60      * <p>Account filtering works the same way: if an account is provided, only
61      * <em>account-dependent</em> file groups matching that account are considered for removal; if
62      * an account is <b>not</b> provided, only <em>account-independent</em> file groups are
63      * considered for removal.
64      */
setAccountOptional(Optional<Account> accountOptional)65     public abstract Builder setAccountOptional(Optional<Account> accountOptional);
66 
build()67     public abstract RemoveFileGroupsByFilterRequest build();
68   }
69 }
70