123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- import defined from "../Core/defined.js";
- import Event from "../Core/Event.js";
- function ConstantProperty(value) {
- this._value = undefined;
- this._hasClone = false;
- this._hasEquals = false;
- this._definitionChanged = new Event();
- this.setValue(value);
- }
- Object.defineProperties(ConstantProperty.prototype, {
-
- isConstant: {
- value: true,
- },
-
- definitionChanged: {
- get: function () {
- return this._definitionChanged;
- },
- },
- });
- ConstantProperty.prototype.getValue = function (time, result) {
- return this._hasClone ? this._value.clone(result) : this._value;
- };
- ConstantProperty.prototype.setValue = function (value) {
- var oldValue = this._value;
- if (oldValue !== value) {
- var isDefined = defined(value);
- var hasClone = isDefined && typeof value.clone === "function";
- var hasEquals = isDefined && typeof value.equals === "function";
- var changed = !hasEquals || !value.equals(oldValue);
- if (changed) {
- this._hasClone = hasClone;
- this._hasEquals = hasEquals;
- this._value = !hasClone ? value : value.clone(this._value);
- this._definitionChanged.raiseEvent(this);
- }
- }
- };
- ConstantProperty.prototype.equals = function (other) {
- return (
- this === other ||
- (other instanceof ConstantProperty &&
- ((!this._hasEquals && this._value === other._value) ||
- (this._hasEquals && this._value.equals(other._value))))
- );
- };
- ConstantProperty.prototype.valueOf = function () {
- return this._value;
- };
- ConstantProperty.prototype.toString = function () {
- return String(this._value);
- };
- export default ConstantProperty;
|