File

src/models/events/idm/administrative-state-event.ts

Description

Serializable REDHAWK IDM Administrative State Event

Extends

IdmStateEvent

Implements

ISerializable

Index

Methods

Methods

deserialize
deserialize(input: any)

Deserializes a JSON object into this class

Parameters :
Name Type Optional Description
input any
Returns : this
import { ISerializable }       from '../../serialization/index';

import { IdmStateEvent }       from './idm-state-event';
import { AdministrativeState } from './enums/index';

/**
 * Serializable REDHAWK IDM Administrative State Event
 */
export class AdministrativeStateEvent
    extends IdmStateEvent<AdministrativeState>
    implements ISerializable<AdministrativeStateEvent> {

    /** Deserializes a JSON object into this class */
    deserialize(input: any) {
        super.deserialize(input);
        this.stateChangeFrom = fromString(input.stateChangeFrom.value);
        this.stateChangeTo = fromString(input.stateChangeTo.value);
        return this;
    }
}

/**
 * Internal helper function for converting to the enumeration value.
 */
function fromString(category: string): AdministrativeState {
    let out = AdministrativeState.UNKNOWN;
    switch (category) {
        case 'LOCKED':
            out = AdministrativeState.LOCKED;
            break;
        case 'UNLOCKED':
            out = AdministrativeState.UNLOCKED;
            break;
        case 'SHUTTING_DOWN':
            out = AdministrativeState.SHUTTING_DOWN;
            break;
        default:
            console.error('Unknown AdministrativeState: ' + category);
            break;
    }
    return out;
}

results matching ""

    No results matching ""