1 /*
2  * Copyright 2019 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 android.media.tv.tuner.filter;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.media.tv.tuner.TunerUtils;
22 
23 /**
24  * Filter Settings for a Download.
25  *
26  * @hide
27  */
28 @SystemApi
29 public class DownloadSettings extends Settings {
30     private final int mDownloadId;
31 
DownloadSettings(int mainType, int downloadId)32     private DownloadSettings(int mainType, int downloadId) {
33         super(TunerUtils.getFilterSubtype(mainType, Filter.SUBTYPE_DOWNLOAD));
34         mDownloadId = downloadId;
35     }
36 
37     /**
38      * Gets download ID.
39      */
getDownloadId()40     public int getDownloadId() {
41         return mDownloadId;
42     }
43 
44     /**
45      * Creates a builder for {@link DownloadSettings}.
46      *
47      * @param mainType the filter main type.
48      */
49     @NonNull
builder(@ilter.Type int mainType)50     public static Builder builder(@Filter.Type int mainType) {
51         return new Builder(mainType);
52     }
53 
54     /**
55      * Builder for {@link DownloadSettings}.
56      */
57     public static class Builder {
58         private final int mMainType;
59         private int mDownloadId;
60 
Builder(int mainType)61         private Builder(int mainType) {
62             mMainType = mainType;
63         }
64 
65         /**
66          * Sets download ID.
67          */
68         @NonNull
setDownloadId(int downloadId)69         public Builder setDownloadId(int downloadId) {
70             mDownloadId = downloadId;
71             return this;
72         }
73 
74         /**
75          * Builds a {@link DownloadSettings} object.
76          */
77         @NonNull
build()78         public DownloadSettings build() {
79             return new DownloadSettings(mMainType, mDownloadId);
80         }
81     }
82 }
83