| Total Complexity | 3 |
| Complexity/F | 1 |
| Lines of Code | 32 |
| Function Count | 3 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | const { Guard } = require('./guard'); |
||
| 2 | |||
| 3 | /** |
||
| 4 | * A node object represents a node in a graph. In graph theory, nodes are also called points or vertices. |
||
| 5 | */ |
||
| 6 | class JgfNode { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Constructor |
||
| 10 | * @param {string} id Primary key for the node, that is unique for the object type. |
||
| 11 | * @param {string} label A text display for the node. |
||
| 12 | * @param {object|null} metadata Metadata about the node. |
||
| 13 | */ |
||
| 14 | constructor(id, label, metadata = null) { |
||
| 15 | this.id = id; |
||
| 16 | this.label = label; |
||
| 17 | this.metadata = metadata; |
||
| 18 | } |
||
| 19 | |||
| 20 | set metadata(metadata) { |
||
| 21 | Guard.assertValidMetadataOrNull(metadata); |
||
| 22 | this._metadata = metadata; |
||
| 23 | } |
||
| 24 | |||
| 25 | get metadata() { |
||
| 26 | return this._metadata; |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | module.exports = { |
||
| 31 | JgfNode, |
||
| 32 | }; |