Files
ueblueprint/js/entity/IdentifierEntity.js
barsdeveloper 78c62ee59a Split grammar (#15)
* Move grammar parsers to entity classes

* Fix includes

* Fix Entity5 test

* Small detail

* Fix unknown keys entities

* Persistent grammar objects

* Fix grammar

* Grammar from variable
2023-09-18 21:13:28 +02:00

43 lines
938 B
JavaScript

import Grammar from "../serialization/Grammar.js"
import IEntity from "./IEntity.js"
export default class IdentifierEntity extends IEntity {
static attributes = {
...super.attributes,
value: {
default: "",
},
}
static {
this.cleanupAttributes(this.attributes)
}
static attributeConverter = {
fromAttribute: (value, type) => new IdentifierEntity(value),
toAttribute: (value, type) => value.toString()
}
static grammar = this.createGrammar()
static createGrammar() {
return Grammar.symbol.map(v => new this(v))
}
constructor(values) {
if (values.constructor !== Object) {
values = {
value: values,
}
}
super(values)
/** @type {String} */ this.value
}
valueOf() {
return this.value
}
toString() {
return this.value
}
}