File

src/models/property/struct-seq-property.ts

Description

Serializable REDHAWK 'structSeq' Property Model

Extends

Property

Implements

ISerializable

Index

Properties
Methods

Methods

copy
copy()

Create a copy of the property.

Returns : StructSeqProperty
deserialize
deserialize(input: any)

Deserializes a JSON object into this class

Parameters :
Name Type Optional Description
input any
Returns : this
find
find(fieldId: string, value: string)

Find a StructProperty having a field whose value matches the provided one.

Parameters :
Name Type Optional Description
fieldId string

The field ID in the StructProprety to use in the match.

value string

The value to locate at fieldId

Returns : StructProperty

Properties

scaType
scaType: ScaStructSeqType
Type : ScaStructSeqType
Default value : 'structSeq'

The SCA Type ('structseq')

value
value: StructSeqValueType
Type : StructSeqValueType

The list of StructPropertys for this struct sequence

import { ISerializable } from '../serialization/index';
import { Property } from './property';
import { StructSeqValueType } from './struct-seq-value-type';
import { ScaStructSeqType } from './sca-types';
import { StructProperty } from './struct-property';

/**
 * Serializable REDHAWK 'structSeq' Property Model
 */
export class StructSeqProperty extends Property implements ISerializable<StructSeqProperty> {
    /** The list of StructPropertys for this struct sequence */
    value: StructSeqValueType;
    /** The SCA Type ('structseq') */
    scaType: ScaStructSeqType = 'structSeq';

    /**
     * Find a StructProperty having a field whose value matches the provided one.
     *
     * @param { string } fieldId The field ID in the StructProprety to use in the match.
     * @param { string } value The value to locate at fieldId
     */
    find(fieldId: string, value: string): StructProperty {
        for (let item of this.value) {
            let field = item.field(fieldId);
            if (field && field.value === value) {
                return item;
            }
        }
        return undefined;
    }

    /** Deserializes a JSON object into this class */
    deserialize(input: any) {
        super.deserialize(input);
        this.scaType = input.scaType;
        this.value = [] as StructSeqValueType;
        for (let sub of input.value) {
            this.value.push(new StructProperty().deserialize(sub));
        }
        return this;
    }

    /**
     * Create a copy of the property.
     */
    copy(): StructSeqProperty {
        const p = new StructSeqProperty().deserialize(this);
        p.kinds = (this.kinds instanceof Array) ? this.kinds.slice() : this.kinds;
        return p;
    }
}

results matching ""

    No results matching ""