Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/sourcetools/objectmodel/com/ibm/j9tools/om/Feature.java
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2007, 2011 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
package com.ibm.j9tools.om;
23
24
import java.util.Map;
25
import java.util.Set;
26
27
/**
28
* @author Gabriel Castro
29
* @since v1.5.0
30
*/
31
public class Feature extends FeatureDefinition implements Comparable<Feature> {
32
private FeatureDefinition featureDefinition;
33
34
/**
35
* Creates a J9 feature reference with the given id.
36
*
37
* @param featureId the id of the feature definition
38
*/
39
public Feature(String featureId) {
40
this.id = featureId;
41
}
42
43
/**
44
* Creates a J9 feature reference from the given {@link FeatureDefinition}. The feature ID
45
* is inherited from the {@link FeatureDefinition}.
46
*
47
* @param featureDefinition the parent definition
48
*/
49
public Feature(FeatureDefinition featureDefinition) {
50
this(featureDefinition.getId());
51
this.setDefinition(featureDefinition);
52
}
53
54
/**
55
* Sets this feature's parent {@link FeatureDefinition}.
56
*
57
* @param featureDefinition the parent definition
58
*/
59
public void setDefinition(FeatureDefinition featureDefinition) {
60
this.featureDefinition = featureDefinition;
61
this.complete = true;
62
}
63
64
/**
65
* Removes this feature's parent {@link FeatureDefinition}.
66
*/
67
public void removeDefinition() {
68
this.featureDefinition = null;
69
this.complete = false;
70
}
71
72
/**
73
* Does nothing as a {@link Property} cannot be added to a {@link Feature}, only to its
74
* parent {@link FeatureDefinition}.
75
*
76
* @see com.ibm.j9tools.om.FeatureDefinition#addProperty(com.ibm.j9tools.om.Property)
77
*/
78
@Override
79
public void addProperty(Property property) {
80
}
81
82
/**
83
* Does nothing as a {@link Property} cannot be added to a {@link Feature}, only to its
84
* parent {@link FeatureDefinition}.
85
*
86
* @see com.ibm.j9tools.om.FeatureDefinition#addAllProperties(java.util.Set)
87
*/
88
@Override
89
public void addAllProperties(Set<String> propertyNames) {
90
}
91
92
/**
93
* Does nothing as a {@link Flag} cannot be added to a {@link Feature}, only to its
94
* parent {@link FeatureDefinition}.
95
*
96
* @see com.ibm.j9tools.om.FeatureDefinition#addAllFlags(java.util.Map)
97
*/
98
@Override
99
public void addAllFlags(Map<String, Flag> flags) {
100
}
101
102
/**
103
* Does nothing as a {@link Flag} cannot be added to a {@link Feature}, only to its
104
* parent {@link FeatureDefinition}.
105
*
106
* @see com.ibm.j9tools.om.FeatureDefinition#addFlag(com.ibm.j9tools.om.Flag)
107
*/
108
@Override
109
public void addFlag(Flag flag) {
110
}
111
112
/**
113
* Does nothing as a {@link Source} cannot be added to a {@link Feature}, only to its
114
* parent {@link FeatureDefinition}.
115
*
116
* @see com.ibm.j9tools.om.FeatureDefinition#addSource(com.ibm.j9tools.om.Source)
117
*/
118
@Override
119
public void addSource(Source source) {
120
}
121
122
/**
123
* Retrieves the name of the parent {@link FeatureDefinition} if one is set.
124
*
125
* @see com.ibm.j9tools.om.FeatureDefinition#getName()
126
*/
127
@Override
128
public String getName() {
129
return (complete) ? featureDefinition.getName() : super.getName();
130
}
131
132
/**
133
* Retrieves the description of the parent {@link FeatureDefinition} if one is set.
134
*
135
* @see com.ibm.j9tools.om.FeatureDefinition#getDescription()
136
*/
137
@Override
138
public String getDescription() {
139
return (complete) ? featureDefinition.getDescription() : super.getDescription();
140
}
141
142
/**
143
* Retrieves the given property from the parent {@link FeatureDefinition} if one is set,
144
* otherwise it returns null;
145
*
146
* @see com.ibm.j9tools.om.FeatureDefinition#getProperty(java.lang.String)
147
*/
148
@Override
149
public Property getProperty(String propertyName) {
150
return (complete) ? featureDefinition.getProperty(propertyName) : super.getProperty(propertyName);
151
}
152
153
/**
154
* Retrieves the properties from the parent {@link FeatureDefinition} if one is set,
155
* otherwise it returns null;
156
*
157
* @see com.ibm.j9tools.om.FeatureDefinition#getProperties()
158
*/
159
@Override
160
public Map<String, Property> getProperties() {
161
return (complete) ? featureDefinition.getProperties() : super.getProperties();
162
}
163
164
/**
165
* Retrieves the given flag from the parent {@link FeatureDefinition} if one is set,
166
* otherwise it returns null;
167
*
168
* @see com.ibm.j9tools.om.FeatureDefinition#getFlag(java.lang.String)
169
*/
170
@Override
171
public Flag getFlag(String flagId) {
172
return (complete) ? featureDefinition.getFlag(flagId) : super.getFlag(flagId);
173
}
174
175
/**
176
* Retrieves the flags from the parent {@link FeatureDefinition} if one is set,
177
* otherwise it returns null;
178
*
179
* @see com.ibm.j9tools.om.FeatureDefinition#getFlags()
180
*/
181
@Override
182
public Map<String, Flag> getFlags() {
183
return (complete) ? featureDefinition.getFlags() : super.getFlags();
184
}
185
186
/**
187
* Retrieves the flags with the given category from the parent {@link FeatureDefinition} if one is set,
188
* otherwise it returns null;
189
*
190
* @see com.ibm.j9tools.om.FeatureDefinition#getFlags(java.lang.String)
191
*/
192
@Override
193
public Map<String, Flag> getFlags(String category) {
194
return (complete) ? featureDefinition.getFlags(category) : super.getFlags(category);
195
}
196
197
/**
198
* Retrieves the given local flag from the parent {@link FeatureDefinition} if one is set,
199
* otherwise it returns null;
200
*
201
* @see com.ibm.j9tools.om.FeatureDefinition#getLocalFlag(java.lang.String)
202
*/
203
@Override
204
public Flag getLocalFlag(String flagId) {
205
return (complete) ? featureDefinition.getLocalFlag(flagId) : super.getLocalFlag(flagId);
206
}
207
208
/**
209
* Retrieves the local flags from the parent {@link FeatureDefinition} if one is set,
210
* otherwise it returns null;
211
*
212
* @see com.ibm.j9tools.om.FeatureDefinition#getLocalFlags()
213
*/
214
@Override
215
public Map<String, Flag> getLocalFlags() {
216
return (complete) ? featureDefinition.getLocalFlags() : super.getLocalFlags();
217
}
218
219
/**
220
* Retrieves the local flags with the given category from the parent {@link FeatureDefinition} if one is set,
221
* otherwise it returns null;
222
*
223
* @see com.ibm.j9tools.om.FeatureDefinition#getLocalFlags(java.lang.String)
224
*/
225
@Override
226
public Map<String, Flag> getLocalFlags(String category) {
227
return (complete) ? featureDefinition.getLocalFlags(category) : super.getLocalFlags(category);
228
}
229
230
/**
231
* Retrieves the given local source from the parent {@link FeatureDefinition} if one is set,
232
* otherwise it returns null;
233
*
234
* @see com.ibm.j9tools.om.FeatureDefinition#getLocalSource(java.lang.String)
235
*/
236
@Override
237
public Source getLocalSource(String sourceId) {
238
return (complete) ? featureDefinition.getLocalSource(sourceId) : super.getLocalSource(sourceId);
239
}
240
241
/**
242
* Retrieves the local sources from the parent {@link FeatureDefinition} if one is set,
243
* otherwise it returns null;
244
*
245
* @see com.ibm.j9tools.om.FeatureDefinition#getLocalSources()
246
*/
247
@Override
248
public Map<String, Source> getLocalSources() {
249
return (complete) ? featureDefinition.getLocalSources() : super.getLocalSources();
250
}
251
252
/**
253
* Retrieves the given source from the parent {@link FeatureDefinition} if one is set,
254
* otherwise it returns null;
255
*
256
* @see com.ibm.j9tools.om.FeatureDefinition#getSource(java.lang.String)
257
*/
258
@Override
259
public Source getSource(String sourceId) {
260
return (complete) ? featureDefinition.getSource(sourceId) : super.getSource(sourceId);
261
}
262
263
/**
264
* @see com.ibm.j9tools.om.FeatureDefinition#getSources()
265
*/
266
@Override
267
public Map<String, Source> getSources() {
268
return (complete) ? featureDefinition.getSources() : super.getSources();
269
}
270
271
/**
272
* Determines if the parent {@link FeatureDefinition} has the given property. If the definition is not
273
* set it returns null.
274
*
275
* @see com.ibm.j9tools.om.FeatureDefinition#hasProperty(java.lang.String)
276
*/
277
@Override
278
public boolean hasProperty(String propertyName) {
279
return (complete) ? featureDefinition.hasProperty(propertyName) : super.hasProperty(propertyName);
280
}
281
282
/**
283
* Determines if the parent {@link FeatureDefinition} has the given flag. If the definition is not
284
* set it returns null.
285
*
286
* @see com.ibm.j9tools.om.FeatureDefinition#hasFlag(java.lang.String)
287
*/
288
@Override
289
public boolean hasFlag(String flagId) {
290
return (complete) ? featureDefinition.hasFlag(flagId) : super.hasFlag(flagId);
291
}
292
293
/**
294
* Determines if the parent {@link FeatureDefinition} has the given local flag. If the definition is not
295
* set it returns null.
296
*
297
* @see com.ibm.j9tools.om.FeatureDefinition#hasLocalFlag(java.lang.String)
298
*/
299
@Override
300
public boolean hasLocalFlag(String flagId) {
301
return (complete) ? featureDefinition.hasLocalFlag(flagId) : super.hasLocalFlag(flagId);
302
}
303
304
/**
305
* Determines if the parent {@link FeatureDefinition} has the given source. If the definition is not
306
* set it returns null.
307
*
308
* @see com.ibm.j9tools.om.FeatureDefinition#hasSource(java.lang.String)
309
*/
310
@Override
311
public boolean hasSource(String sourceId) {
312
return (complete) ? featureDefinition.hasSource(sourceId) : super.hasSource(sourceId);
313
}
314
315
/**
316
* Determines if the parent {@link FeatureDefinition} has the given local source. If the definition is not
317
* set it returns null.
318
*
319
* @see com.ibm.j9tools.om.FeatureDefinition#hasLocalSource(java.lang.String)
320
*/
321
@Override
322
public boolean hasLocalSource(String sourceId) {
323
return (complete) ? featureDefinition.hasLocalSource(sourceId) : super.hasLocalSource(sourceId);
324
}
325
326
/**
327
* Does nothing as a {@link Property} cannot be removed from a {@link Feature}, only from
328
* a {@link FeatureDefinition}.
329
*
330
* @see com.ibm.j9tools.om.FeatureDefinition#removeProperty(com.ibm.j9tools.om.Property)
331
*/
332
@Override
333
public void removeProperty(Property property) {
334
}
335
336
/**
337
* Does nothing as a {@link Property} cannot be removed from a {@link Feature}, only from
338
* a {@link FeatureDefinition}.
339
*
340
* @see com.ibm.j9tools.om.FeatureDefinition#removeProperty(java.lang.String)
341
*/
342
@Override
343
public void removeProperty(String propertyName) {
344
}
345
346
/**
347
* Does nothing as a {@link Flag} cannot be removed from a {@link Feature}, only from
348
* a {@link FeatureDefinition}.
349
*
350
* @see com.ibm.j9tools.om.FeatureDefinition#removeFlag(com.ibm.j9tools.om.Flag)
351
*/
352
@Override
353
public void removeFlag(Flag flag) {
354
}
355
356
/**
357
* Does nothing as a {@link Flag} cannot be removed from a {@link Feature}, only from
358
* a {@link FeatureDefinition}.
359
*
360
* @see com.ibm.j9tools.om.FeatureDefinition#removeFlag(java.lang.String)
361
*/
362
@Override
363
public void removeFlag(String flagId) {
364
}
365
366
/**
367
* Does nothing as a {@link Source} cannot be removed from a {@link Feature}, only from
368
* a {@link FeatureDefinition}.
369
*
370
* @see com.ibm.j9tools.om.FeatureDefinition#removeSource(java.lang.String)
371
*/
372
@Override
373
public void removeSource(String sourceId) {
374
}
375
376
/**
377
* Does nothing as a {@link Source} cannot be removed from a {@link Feature}, only from
378
* a {@link FeatureDefinition}.
379
*
380
* @see com.ibm.j9tools.om.FeatureDefinition#setDescription(java.lang.String)
381
*/
382
@Override
383
public void setDescription(String description) {
384
}
385
386
/**
387
* Does nothing as the name of a {@link Feature} cannot be changed. The name is
388
* inherited from it's {@link FeatureDefinition}.
389
*
390
* @see com.ibm.j9tools.om.FeatureDefinition#setName(java.lang.String)
391
*/
392
@Override
393
public void setName(String name) {
394
}
395
396
/**
397
* @see java.lang.Comparable#compareTo(java.lang.Object)
398
*/
399
public int compareTo(Feature o) {
400
return id.compareToIgnoreCase(o.id);
401
}
402
403
/**
404
* @see java.lang.Object#equals(java.lang.Object)
405
*/
406
@Override
407
public boolean equals(Object o) {
408
return (o instanceof Feature) ? id.equals(((Feature) o).id) : false;
409
}
410
411
}
412
413