• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package ohos.devtools.datasources.utils.session.entity;
17 
18 import ohos.devtools.datasources.utils.device.entity.DeviceIPPortInfo;
19 import ohos.devtools.datasources.utils.process.entity.ProcessInfo;
20 
21 /**
22  * SessionInfo实体
23  *
24  * @since 2021/5/19 16:39
25  */
26 public class SessionInfo {
27     private String sessionName;
28     private int sessionId;
29     private long startTimestamp;
30     private long endTimestamp;
31     private long streamId;
32     private int pid;
33     private String processName;
34     private boolean startRefsh;
35     private boolean offlineMode;
36     private final DeviceIPPortInfo deviceIPPortInfo;
37     private ProcessInfo processInfo;
38     private long secondSessionId;
39 
SessionInfo(Builder builder)40     private SessionInfo(Builder builder) {
41         sessionName = builder.sessionName;
42         sessionId = builder.sessionId;
43         startTimestamp = builder.startTimestamp;
44         endTimestamp = builder.endTimestamp;
45         streamId = builder.streamId;
46         pid = builder.pid;
47         processName = builder.processName;
48         deviceIPPortInfo = builder.deviceIPPortInfo;
49         processInfo = builder.processInfo;
50     }
51 
52     /**
53      * builder
54      *
55      * @return Builder
56      */
builder()57     public static Builder builder() {
58         return new Builder();
59     }
60 
getProcessName()61     public String getProcessName() {
62         return processName;
63     }
64 
setProcessName(String processName)65     public void setProcessName(String processName) {
66         this.processName = processName;
67     }
68 
getDeviceIPPortInfo()69     public DeviceIPPortInfo getDeviceIPPortInfo() {
70         return deviceIPPortInfo;
71     }
72 
getSessionName()73     public String getSessionName() {
74         return sessionName;
75     }
76 
setSessionName(String sessionName)77     public void setSessionName(String sessionName) {
78         this.sessionName = sessionName;
79     }
80 
getSessionId()81     public int getSessionId() {
82         return sessionId;
83     }
84 
setSessionId(int sessionId)85     public void setSessionId(int sessionId) {
86         this.sessionId = sessionId;
87     }
88 
getStartTimestamp()89     public long getStartTimestamp() {
90         return startTimestamp;
91     }
92 
setStartTimestamp(long startTimestamp)93     public void setStartTimestamp(long startTimestamp) {
94         this.startTimestamp = startTimestamp;
95     }
96 
getEndTimestamp()97     public long getEndTimestamp() {
98         return endTimestamp == 0 ? Long.MAX_VALUE : endTimestamp;
99     }
100 
setEndTimestamp(long endTimestamp)101     public void setEndTimestamp(long endTimestamp) {
102         this.endTimestamp = endTimestamp;
103     }
104 
getStreamId()105     public long getStreamId() {
106         return streamId;
107     }
108 
setStreamId(long streamId)109     public void setStreamId(long streamId) {
110         this.streamId = streamId;
111     }
112 
getPid()113     public int getPid() {
114         return pid;
115     }
116 
setPid(int pid)117     public void setPid(int pid) {
118         this.pid = pid;
119     }
120 
isOfflineMode()121     public boolean isOfflineMode() {
122         return offlineMode;
123     }
124 
setOfflineMode(boolean offlineMode)125     public void setOfflineMode(boolean offlineMode) {
126         this.offlineMode = offlineMode;
127     }
128 
isStartRefsh()129     public boolean isStartRefsh() {
130         return startRefsh;
131     }
132 
setStartRefsh(boolean startRefsh)133     public void setStartRefsh(boolean startRefsh) {
134         this.startRefsh = startRefsh;
135     }
136 
getProcessInfo()137     public ProcessInfo getProcessInfo() {
138         return processInfo;
139     }
140 
setProcessInfo(ProcessInfo processInfo)141     public void setProcessInfo(ProcessInfo processInfo) {
142         this.processInfo = processInfo;
143     }
144 
getSecondSessionId()145     public long getSecondSessionId() {
146         return secondSessionId;
147     }
148 
setSecondSessionId(long secondSessionId)149     public void setSecondSessionId(long secondSessionId) {
150         this.secondSessionId = secondSessionId;
151     }
152 
153     /**
154      * Builder
155      */
156     public static class Builder {
157         private String sessionName;
158         private int sessionId;
159         private long startTimestamp;
160         private long endTimestamp;
161         private long streamId;
162         private int pid;
163         private String processName;
164         private DeviceIPPortInfo deviceIPPortInfo;
165         private ProcessInfo processInfo;
166 
Builder()167         private Builder() {
168         }
169 
170         /**
171          * sessionName
172          *
173          * @param sessionName sessionName
174          * @return Builder
175          */
sessionName(String sessionName)176         public Builder sessionName(String sessionName) {
177             this.sessionName = sessionName;
178             return this;
179         }
180 
181         /**
182          * sessionId
183          *
184          * @param sessionId sessionId
185          * @return Builder
186          */
sessionId(int sessionId)187         public Builder sessionId(int sessionId) {
188             this.sessionId = sessionId;
189             return this;
190         }
191 
192         /**
193          * startTimestamp
194          *
195          * @param startTimestamp startTimestamp
196          * @return Builder
197          */
startTimestamp(long startTimestamp)198         public Builder startTimestamp(long startTimestamp) {
199             this.startTimestamp = startTimestamp;
200             return this;
201         }
202 
203         /**
204          * endTimestamp
205          *
206          * @param endTimestamp endTimestamp
207          * @return Builder
208          */
endTimestamp(long endTimestamp)209         public Builder endTimestamp(long endTimestamp) {
210             this.endTimestamp = endTimestamp;
211             return this;
212         }
213 
214         /**
215          * streamId
216          *
217          * @param streamId streamId
218          * @return Builder
219          */
streamId(long streamId)220         public Builder streamId(long streamId) {
221             this.streamId = streamId;
222             return this;
223         }
224 
225         /**
226          * 获取pid信息方法
227          *
228          * @param pid pid
229          * @return Builder
230          */
pid(int pid)231         public Builder pid(int pid) {
232             this.pid = pid;
233             return this;
234         }
235 
236         /**
237          * 获取processName信息方法
238          *
239          * @param processName processName
240          * @return Builder
241          */
processName(String processName)242         public Builder processName(String processName) {
243             this.processName = processName;
244             return this;
245         }
246 
247         /**
248          * 设备IP和端口号信息
249          *
250          * @param deviceIPPortInfo deviceIPPortInfo
251          * @return Builder
252          */
deviceIPPortInfo(DeviceIPPortInfo deviceIPPortInfo)253         public Builder deviceIPPortInfo(DeviceIPPortInfo deviceIPPortInfo) {
254             this.deviceIPPortInfo = deviceIPPortInfo;
255             return this;
256         }
257 
258         /**
259          * Process information
260          *
261          * @param processInfo processInfo
262          * @return Builder
263          */
processInfo(ProcessInfo processInfo)264         public Builder processInfo(ProcessInfo processInfo) {
265             this.processInfo = processInfo;
266             return this;
267         }
268 
269         /**
270          * build方法
271          *
272          * @return SessionInfo
273          */
build()274         public SessionInfo build() {
275             return new SessionInfo(this);
276         }
277     }
278 }
279