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.providers.media.dao;
18 
19 /** DAO object representing database row of Files table of a MediaProvider database. */
20 public class FileRow {
21 
22     private final long mId;
23     private String mPath;
24     private String mOwnerPackageName;
25     private String mVolumeName;
26     private int mMediaType;
27     private boolean mIsDownload;
28     private boolean mIsPending;
29     private boolean mIsTrashed;
30     private boolean mIsFavorite;
31     private int mSpecialFormat;
32     private int mUserId;
33     // String data type used as value can be null
34     private String mDateExpires;
35 
36     public static class Builder {
37         private final long mId;
38         private String mPath;
39         private String mOwnerPackageName;
40         private String mVolumeName;
41         private int mMediaType;
42         private boolean mIsDownload;
43         private boolean mIsPending;
44         private boolean mIsTrashed;
45         private boolean mIsFavorite;
46         private int mSpecialFormat;
47         private int mUserId;
48         private String mDateExpires;
49 
Builder(long id)50         Builder(long id) {
51             this.mId = id;
52         }
53 
setPath(String path)54         public Builder setPath(String path) {
55             this.mPath = path;
56             return this;
57         }
58 
setOwnerPackageName(String ownerPackageName)59         public Builder setOwnerPackageName(String ownerPackageName) {
60             this.mOwnerPackageName = ownerPackageName;
61             return this;
62         }
63 
setVolumeName(String volumeName)64         public Builder setVolumeName(String volumeName) {
65             this.mVolumeName = volumeName;
66             return this;
67         }
68 
setMediaType(int mediaType)69         public Builder setMediaType(int mediaType) {
70             this.mMediaType = mediaType;
71             return this;
72         }
73 
setIsDownload(boolean download)74         public Builder setIsDownload(boolean download) {
75             mIsDownload = download;
76             return this;
77         }
78 
setIsPending(boolean pending)79         public Builder setIsPending(boolean pending) {
80             mIsPending = pending;
81             return this;
82         }
83 
setIsTrashed(boolean trashed)84         public Builder setIsTrashed(boolean trashed) {
85             mIsTrashed = trashed;
86             return this;
87         }
88 
setIsFavorite(boolean favorite)89         public Builder setIsFavorite(boolean favorite) {
90             mIsFavorite = favorite;
91             return this;
92         }
93 
setSpecialFormat(int specialFormat)94         public Builder setSpecialFormat(int specialFormat) {
95             this.mSpecialFormat = specialFormat;
96             return this;
97         }
98 
setUserId(int userId)99         public Builder setUserId(int userId) {
100             this.mUserId = userId;
101             return this;
102         }
103 
setDateExpires(String dateExpires)104         public Builder setDateExpires(String dateExpires) {
105             this.mDateExpires = dateExpires;
106             return this;
107         }
108 
build()109         public FileRow build() {
110             FileRow fileRow = new FileRow(this.mId);
111             fileRow.mPath = this.mPath;
112             fileRow.mOwnerPackageName = this.mOwnerPackageName;
113             fileRow.mVolumeName = this.mVolumeName;
114             fileRow.mMediaType = this.mMediaType;
115             fileRow.mIsDownload = this.mIsDownload;
116             fileRow.mIsPending = this.mIsPending;
117             fileRow.mIsTrashed = this.mIsTrashed;
118             fileRow.mIsFavorite = this.mIsFavorite;
119             fileRow.mSpecialFormat = this.mSpecialFormat;
120             fileRow.mUserId = this.mUserId;
121             fileRow.mDateExpires = this.mDateExpires;
122 
123             return fileRow;
124         }
125     }
126 
newBuilder(long id)127     public static Builder newBuilder(long id) {
128         return new Builder(id);
129     }
130 
FileRow(long id)131     private FileRow(long id) {
132         this.mId = id;
133     }
134 
getId()135     public long getId() {
136         return mId;
137     }
138 
getPath()139     public String getPath() {
140         return mPath;
141     }
142 
getOwnerPackageName()143     public String getOwnerPackageName() {
144         return mOwnerPackageName;
145     }
146 
getVolumeName()147     public String getVolumeName() {
148         return mVolumeName;
149     }
150 
getMediaType()151     public int getMediaType() {
152         return mMediaType;
153     }
154 
isDownload()155     public boolean isDownload() {
156         return mIsDownload;
157     }
158 
isPending()159     public boolean isPending() {
160         return mIsPending;
161     }
162 
isTrashed()163     public boolean isTrashed() {
164         return mIsTrashed;
165     }
166 
isFavorite()167     public boolean isFavorite() {
168         return mIsFavorite;
169     }
170 
getSpecialFormat()171     public int getSpecialFormat() {
172         return mSpecialFormat;
173     }
174 
getUserId()175     public int getUserId() {
176         return mUserId;
177     }
178 
getDateExpires()179     public String getDateExpires() {
180         return mDateExpires;
181     }
182 }
183