import { Node } from './Node';
import { JSONValue, JSExpression } from '../types';

export interface PropOptions {
  name: string;
  value: JSONValue | JSExpression;
  defaultValue: JSONValue;
}

export class Prop {
  isUnset: boolean = false;
  name: string;
  value: JSONValue | JSExpression;
  defaultValue: JSONValue;

  constructor(options: PropOptions) {
    this.name = options.name;
    this.defaultValue = options.defaultValue;
    this.setValue(options.value);
  }
  getValue() {
    return this.value;
  }

  setValue(value: any) {
    this.value = value;
    this.isUnset = this.value === this.defaultValue;
  }
}
