/** * Returns a list containing the property names assigned to the input * * @return {Array<string>} */ propertyNames(){ return [...new Set([...this[_properties].keys(), ...Input._allRegisteredProperties(this.constructor).keys(), ])]; }
/** * Returns the property value for the input property name * * @param {string} name - name of the property * @return {Promise<*>} The value of the property otherwise raises an exception * in case the property is not assigned */ property(name){ assert(TypeCheck.isString(name), 'property name needs to be defined as string'); if (this[_properties].has(name)){ return this[_properties].get(name); } // checking if the property is valid const allRegisteredProperties = Input._allRegisteredProperties(this.constructor); if (allRegisteredProperties.has(name)){ return allRegisteredProperties.get(name); } throw new Error(`Property ${name} is not registered!`); }
/** * Returns a boolean telling if the input property name is assigned to the input * * @param {string} name - name of the property * @return {boolean} */ hasProperty(name){ assert(TypeCheck.isString(name), 'property name needs to be defined as string'); return Input._allRegisteredProperties(this.constructor).has(name) || this[_properties].has(name); }
if (!loose && !Input._allRegisteredProperties(this.constructor).has(name)){ throw new Error(`Property ${name} is not registered!`);