• 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.plugin.entity;
17 
18 import ohos.devtools.datasources.utils.datahandler.datapoller.AbsDataConsumer;
19 import ohos.devtools.datasources.utils.device.entity.DeviceType;
20 import ohos.devtools.datasources.utils.plugin.ICreatePluginConfig;
21 import ohos.devtools.datasources.utils.plugin.IGetPluginName;
22 import ohos.devtools.datasources.utils.plugin.ISpecialStartPlugMethod;
23 import ohos.devtools.views.layout.chartview.ProfilerMonitorItem;
24 
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.Objects;
28 
29 /**
30  * PluginConf
31  *
32  * @since 2021/5/19 16:39
33  */
34 public final class PluginConf {
35     private String pluginFileName;
36     private String pluginDataName;
37     private IGetPluginName IGetPluginName;
38     private boolean isEnable = true;
39     private PluginMode pluginMode;
40     private Class<? extends AbsDataConsumer> consumerClass;
41     private boolean isChartPlugin;
42     private ProfilerMonitorItem monitorItem;
43     private PluginBufferConfig pluginBufferConfig;
44     private ICreatePluginConfig ICreatePluginConfig;
45     private boolean isSpecialStart;
46     private ISpecialStartPlugMethod ISpecialStartPlugMethod;
47     private boolean isAlwaysAdd;
48     private boolean operationStart = false;
49     private List<AnalysisType> analysisTypes = new ArrayList<>();
50     private List<DeviceType> supportDeviceTypes = new ArrayList<>();
51 
52     /**
53      * PluginConf
54      *
55      * @param pluginFileName pluginFileName
56      * @param pluginDataName pluginDataName
57      * @param consumerClass consumerClass
58      * @param isChartPlugin isChartPlugin
59      * @param monitorItem monitorItem
60      */
PluginConf(String pluginFileName, String pluginDataName, Class<? extends AbsDataConsumer> consumerClass, boolean isChartPlugin, ProfilerMonitorItem monitorItem)61     public PluginConf(String pluginFileName, String pluginDataName, Class<? extends AbsDataConsumer> consumerClass,
62         boolean isChartPlugin, ProfilerMonitorItem monitorItem) {
63         this.pluginFileName = pluginFileName;
64         this.pluginDataName = pluginDataName;
65         this.consumerClass = consumerClass;
66         this.isChartPlugin = isChartPlugin;
67         this.monitorItem = monitorItem;
68     }
69 
70     /**
71      * getPluginMode
72      *
73      * @return PluginMode
74      */
getPluginMode()75     public PluginMode getPluginMode() {
76         return pluginMode;
77     }
78 
79     /**
80      * setPluginMode
81      *
82      * @param pluginMode pluginMode
83      */
setPluginMode(PluginMode pluginMode)84     public void setPluginMode(PluginMode pluginMode) {
85         this.pluginMode = pluginMode;
86     }
87 
88     /**
89      * getMonitorItem
90      *
91      * @return ProfilerMonitorItem
92      */
getMonitorItem()93     public ProfilerMonitorItem getMonitorItem() {
94         return monitorItem;
95     }
96 
97     /**
98      * setMonitorItem
99      *
100      * @param monitorItem monitorItem
101      */
setMonitorItem(ProfilerMonitorItem monitorItem)102     public void setMonitorItem(ProfilerMonitorItem monitorItem) {
103         this.monitorItem = monitorItem;
104     }
105 
106     /**
107      * isChartPlugin
108      *
109      * @return boolean
110      */
isChartPlugin()111     public boolean isChartPlugin() {
112         return isChartPlugin;
113     }
114 
115     /**
116      * setChartPlugin
117      *
118      * @param chartPlugin chartPlugin
119      */
setChartPlugin(boolean chartPlugin)120     public void setChartPlugin(boolean chartPlugin) {
121         isChartPlugin = chartPlugin;
122     }
123 
124     /**
125      * getPluginBufferConfig
126      *
127      * @return PluginBufferConfig
128      */
getPluginBufferConfig()129     public PluginBufferConfig getPluginBufferConfig() {
130         if (pluginBufferConfig == null) {
131             return new PluginBufferConfig(10, PluginBufferConfig.Policy.RECYCLE);
132         }
133         return pluginBufferConfig;
134     }
135 
136     /**
137      * setPluginBufferConfig
138      *
139      * @param pluginBufferConfig pluginBufferConfig
140      */
setPluginBufferConfig(PluginBufferConfig pluginBufferConfig)141     public void setPluginBufferConfig(PluginBufferConfig pluginBufferConfig) {
142         this.pluginBufferConfig = pluginBufferConfig;
143     }
144 
145     /**
146      * getICreatePluginConfig
147      *
148      * @return ICreatePluginConfig
149      */
getICreatePluginConfig()150     public ICreatePluginConfig getICreatePluginConfig() {
151         return ICreatePluginConfig;
152     }
153 
154     /**
155      * setICreatePluginConfig
156      *
157      * @param ICreatePluginConfig ICreatePluginConfig
158      */
setICreatePluginConfig(ICreatePluginConfig ICreatePluginConfig)159     public void setICreatePluginConfig(ICreatePluginConfig ICreatePluginConfig) {
160         this.ICreatePluginConfig = ICreatePluginConfig;
161     }
162 
163     /**
164      * getPluginFileName
165      *
166      * @return String
167      */
getPluginFileName()168     public String getPluginFileName() {
169         return pluginFileName;
170     }
171 
172     /**
173      * setPluginFileName
174      *
175      * @param pluginFileName pluginFileName
176      */
setPluginFileName(String pluginFileName)177     public void setPluginFileName(String pluginFileName) {
178         this.pluginFileName = pluginFileName;
179     }
180 
181     /**
182      * getPluginDataName
183      *
184      * @return String
185      */
getPluginDataName()186     public String getPluginDataName() {
187         return pluginDataName;
188     }
189 
190     /**
191      * isSpecialStart
192      *
193      * @return boolean
194      */
isSpecialStart()195     public boolean isSpecialStart() {
196         return isSpecialStart;
197     }
198 
199     /**
200      * setSpecialStart
201      *
202      * @param specialStart specialStart
203      */
setSpecialStart(boolean specialStart)204     public void setSpecialStart(boolean specialStart) {
205         isSpecialStart = specialStart;
206     }
207 
208     /**
209      * getSpecialStartPlugMethod
210      *
211      * @return ISpecialStartPlugMethod
212      */
getSpecialStartPlugMethod()213     public ISpecialStartPlugMethod getSpecialStartPlugMethod() {
214         return ISpecialStartPlugMethod;
215     }
216 
217     /**
218      * setSpecialStartPlugMethod
219      *
220      * @param ISpecialStartPlugMethod ISpecialStartPlugMethod
221      */
setSpecialStartPlugMethod(ISpecialStartPlugMethod ISpecialStartPlugMethod)222     public void setSpecialStartPlugMethod(ISpecialStartPlugMethod ISpecialStartPlugMethod) {
223         this.ISpecialStartPlugMethod = ISpecialStartPlugMethod;
224     }
225 
226     /**
227      * setPluginDataName
228      *
229      * @param pluginDataName pluginDataName
230      */
setPluginDataName(String pluginDataName)231     public void setPluginDataName(String pluginDataName) {
232         this.pluginDataName = pluginDataName;
233     }
234 
235     /**
236      * isEnable
237      *
238      * @return boolean
239      */
isEnable()240     public boolean isEnable() {
241         return isEnable;
242     }
243 
244     /**
245      * setEnable
246      *
247      * @param enable enable
248      */
setEnable(boolean enable)249     public void setEnable(boolean enable) {
250         isEnable = enable;
251     }
252 
253     /**
254      * getConsumerClass
255      *
256      * @return Class<? extends AbsDataConsumer>
257      */
getConsumerClass()258     public Class<? extends AbsDataConsumer> getConsumerClass() {
259         return consumerClass;
260     }
261 
262     /**
263      * setConsumerClass
264      *
265      * @param consumerClass consumerClass
266      */
setConsumerClass(Class<? extends AbsDataConsumer> consumerClass)267     public void setConsumerClass(Class<? extends AbsDataConsumer> consumerClass) {
268         this.consumerClass = consumerClass;
269     }
270 
271     /**
272      * getSupportDeviceTypes
273      *
274      * @return List<DeviceType>
275      */
getSupportDeviceTypes()276     public List<DeviceType> getSupportDeviceTypes() {
277         return supportDeviceTypes;
278     }
279 
280     /**
281      * addSupportDeviceTypes
282      *
283      * @param supportDeviceTypes supportDeviceTypes
284      */
addSupportDeviceTypes(DeviceType supportDeviceTypes)285     public void addSupportDeviceTypes(DeviceType supportDeviceTypes) {
286         this.supportDeviceTypes.add(supportDeviceTypes);
287     }
288 
289     /**
290      * setGetPluginName
291      *
292      * @param IGetPluginName IGetPluginName
293      */
setGetPluginName(IGetPluginName IGetPluginName)294     public void setGetPluginName(IGetPluginName IGetPluginName) {
295         this.IGetPluginName = IGetPluginName;
296     }
297 
298     /**
299      * getGetPluginName
300      *
301      * @return IGetPluginName
302      */
getGetPluginName()303     public IGetPluginName getGetPluginName() {
304         return IGetPluginName;
305     }
306 
307     /**
308      * isAlwaysAdd
309      *
310      * @return boolean
311      */
isAlwaysAdd()312     public boolean isAlwaysAdd() {
313         return isAlwaysAdd;
314     }
315 
316     /**
317      * setAlwaysAdd
318      *
319      * @param alwaysAdd alwaysAdd
320      */
setAlwaysAdd(boolean alwaysAdd)321     public void setAlwaysAdd(boolean alwaysAdd) {
322         isAlwaysAdd = alwaysAdd;
323     }
324 
325     /**
326      * isOperationStart
327      *
328      * @return boolean
329      */
isOperationStart()330     public boolean isOperationStart() {
331         return operationStart;
332     }
333 
334     /**
335      * setOperationStart
336      *
337      * @param operationStart operationStart
338      */
setOperationStart(boolean operationStart)339     public void setOperationStart(boolean operationStart) {
340         this.operationStart = operationStart;
341     }
342 
343     @Override
equals(Object obj)344     public boolean equals(Object obj) {
345         if (this == obj) {
346             return true;
347         }
348         if (obj == null || getClass() != obj.getClass()) {
349             return false;
350         }
351         PluginConf that = (PluginConf) obj;
352         return pluginFileName.equals(that.pluginFileName);
353     }
354 
355     /**
356      * get AnalysisTypes
357      *
358      * @return List<AnalysisType>
359      */
getAnalysisTypes()360     public List<AnalysisType> getAnalysisTypes() {
361         return analysisTypes;
362     }
363 
364     /**
365      * add AnalysisTypes
366      *
367      * @param analysisType analysisType
368      */
addAnalysisTypes(AnalysisType analysisType)369     public void addAnalysisTypes(AnalysisType analysisType) {
370         this.analysisTypes.add(analysisType);
371     }
372 
373     @Override
hashCode()374     public int hashCode() {
375         return Objects.hash(pluginFileName);
376     }
377 
378     @Override
toString()379     public String toString() {
380         return "PluginConf{"
381             + "pluginFileName='" + pluginFileName + '\''
382             + ", pluginDataName='" + pluginDataName + '\''
383             + ", IGetPluginName=" + IGetPluginName
384             + ", isEnable=" + isEnable
385             + ", pluginMode=" + pluginMode
386             + ", consumerClass=" + consumerClass
387             + ", isChartPlugin=" + isChartPlugin
388             + ", monitorItem=" + monitorItem
389             + ", pluginBufferConfig=" + pluginBufferConfig
390             + ", ICreatePluginConfig=" + ICreatePluginConfig
391             + ", isSpecialStart=" + isSpecialStart
392             + ", ISpecialStartPlugMethod=" + ISpecialStartPlugMethod
393             + ", isAlwaysAdd=" + isAlwaysAdd
394             + ", operationStart=" + operationStart
395             + ", supportDeviceTypes=" + supportDeviceTypes
396             + '}';
397     }
398 }