storeObject.js 594 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. export class StoreObject {
  2. constructor (type, value, readOnly = false) {
  3. this._type = type;
  4. this._value = value;
  5. this._readOnly = readOnly;
  6. this._id = null;
  7. }
  8. setID (id) {
  9. this._id = id;
  10. }
  11. get id () {
  12. return this._id;
  13. }
  14. get inStore () {
  15. return this.id !== null;
  16. }
  17. get type () {
  18. return this._type;
  19. }
  20. get value () {
  21. return this._value;
  22. }
  23. get readOnly () {
  24. return this._readOnly;
  25. }
  26. isCompatible (another) {
  27. if( another instanceof StoreObject) {
  28. return this.type === another.type;
  29. }
  30. return false;
  31. }
  32. }