File

src/models/property/simple-property.ts

Description

Serializable REDHAWK 'simple' Property Model

Extends

SimpleCommon

Implements

ISerializable

Index

Properties
Methods

Methods

copy
copy()

Create a copy of the property.

Returns : SimpleProperty
deserialize
deserialize(input: any)

Deserializes a JSON object into this class

Parameters :
Name Type Optional Description
input any
Returns : this
valueFromString
valueFromString(val: string)

Update the value from the string vs. type off this property

Parameters :
Name Type Optional Description
val string

The string value to convert based on the type

Returns : void

Properties

scaType
scaType: ScaSimpleType
Type : ScaSimpleType
Default value : 'simple'

SCA Type ('simple')

value
value: SimpleValueType
Type : SimpleValueType

value of the property

import { ISerializable } from '../serialization/index';
import { SimpleCommon } from './simple-common';
import { SimpleValueType } from './simple-value-type';
import { ScaSimpleType } from './sca-types';

/**
 * Serializable REDHAWK 'simple' Property Model
 */
export class SimpleProperty extends SimpleCommon implements ISerializable<SimpleProperty> {
    /** value of the property */
    value:   SimpleValueType;
    /** SCA Type ('simple') */
    scaType: ScaSimpleType = 'simple';

    /** Deserializes a JSON object into this class */
    deserialize(input: any) {
        super.deserialize(input);
        this.scaType = input.scaType;
        this.type = input.type;
        this.enumerations = input.enumerations;
        if (!input.value) {
            this.valueFromString('');
        } else {
            this.value = input.value;
        }
        return this;
    }

    /**
     * Create a copy of the property.
     */
    copy(): SimpleProperty {
        // SimpleCommon handles type, enumerations
        // This creates an initial copy as the base class,
        // merges this instance's changes and then deserializes
        // a copy as this class.
        let p = super.copy();
        p.scaType = this.scaType;
        p.value = this.value;
        return new SimpleProperty().deserialize(p);
    }

    /**
     * Update the value from the string vs. type off this property
     * @param val The string value to convert based on the type
     */
    valueFromString(val: string) {
        this.value = SimpleCommon.valueFromString(val, this.type);
    }
}

results matching ""

    No results matching ""