1 | /*
|
2 | * Licensed under the Apache License, Version 2.0 (the "License");
|
3 | * you may not use this file except in compliance with the License.
|
4 | * You may obtain a copy of the License at
|
5 | *
|
6 | * http://www.apache.org/licenses/LICENSE-2.0
|
7 | *
|
8 | * Unless required by applicable law or agreed to in writing, software
|
9 | * distributed under the License is distributed on an "AS IS" BASIS,
|
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11 | * See the License for the specific language governing permissions and
|
12 | * limitations under the License.
|
13 | */
|
14 |
|
15 | ;
|
16 |
|
17 | const Property = require('./property');
|
18 |
|
19 | /**
|
20 | * Class representing a value from a set of enumerated values
|
21 | *
|
22 | * @extends Property
|
23 | * @see See {@link Property}
|
24 | * @class
|
25 | * @memberof module:concerto-core
|
26 | */
|
27 | class EnumValueDeclaration extends Property {
|
28 |
|
29 | /**
|
30 | * Create a EnumValueDeclaration.
|
31 | * @param {ClassDeclaration} parent - The owner of this property
|
32 | * @param {Object} ast - The AST created by the parser
|
33 | * @throws {IllegalModelException}
|
34 | */
|
35 | constructor(parent, ast) {
|
36 | super(parent, ast);
|
37 | this._isEnumValueDeclaration = true;
|
38 | }
|
39 |
|
40 | /**
|
41 | * Validate the property
|
42 | * @param {ClassDeclaration} classDecl the class declaration of the property
|
43 | * @throws {IllegalModelException}
|
44 | * @private
|
45 | */
|
46 | validate(classDecl) {
|
47 | super.validate(classDecl);
|
48 | }
|
49 |
|
50 | /**
|
51 | * Alternative instanceof that is reliable across different module instances
|
52 | * @see https://github.com/hyperledger/composer-concerto/issues/47
|
53 | *
|
54 | * @param {object} object - The object to test against
|
55 | * @returns {boolean} - True, if the object is an instance of a EnumValueDeclaration
|
56 | */
|
57 | static [Symbol.hasInstance](object){
|
58 | return typeof object !== 'undefined' && object !== null && Boolean(object._isEnumValueDeclaration);
|
59 | }
|
60 | }
|
61 |
|
62 | module.exports = EnumValueDeclaration;
|