import { CoatyObject , CommunicationEventType , CoreTypes , isPlainObject } from ".." ; import { CommunicationEvent , CommunicationEventData } from "./communication-event" ; /**
 * Channel event.
 */ export class ChannelEvent extends CommunicationEvent < ChannelEventData > { get eventType ( ) { return CommunicationEventType . Channel ; } get eventTypeFilter ( ) { return this . _channelId ; } get channelId ( ) { return this . _channelId ; } private _channelId : string ; internal param channelId param eventData throws constructor ( channelId , eventData ) { super ( eventData ) ; if ( ! CommunicationEvent . isValidEventFilter ( channelId ) ) { throw new TypeError ( "in ChannelEvent: argument 'channelId' is not a valid channel identifier" ) ; } this . _channelId = channelId ; } param object param privateData throws static withObject ( channelId , object , privateData ? ) { return new ChannelEvent ( channelId , new ChannelEventData ( object , undefined , privateData ) ) ; } param objects param privateData throws static withObjects ( channelId , objects , privateData ? ) { return new ChannelEvent ( channelId , new ChannelEventData ( undefined , objects , privateData ) ) ; } } /**
 * Defines event data format for channelizing objects.
 */ export class ChannelEventData extends CommunicationEventData { private _object : CoatyObject ; private _objects : CoatyObject [ ] ; private _privateData : { [ key ] : any ; } ; param object param objects param privateData constructor ( object ? , objects ? , privateData ? ) { super ( ) ; this . _object = object ; this . _objects = objects ; this . _privateData = privateData ; if ( ! this . _hasValidParameters ( ) ) { throw new TypeError ( "in ChannelEventData: arguments not valid" ) ; } } internal static createFrom ( eventData ) { return new ChannelEventData ( eventData . object , eventData . objects , eventData . privateData ) ; } /**
     * The object to be channelized.
     */ get object ( ) { return this . _object ; } /**
     * The objects to be channelized.
     */ get objects ( ) { return this . _objects ; } /**
     * Application-specific options as an object hash (optional).
     */ get privateData ( ) { return this . _privateData ; } toJsonObject ( ) { return { object : this . _object , objects : this . _objects , privateData : this . _privateData , } ; } private _hasValidParameters ( ) { return this . _isValidPrivateData ( ) && ( ( this . _objects === undefined && CoreTypes . isObject ( this . _object ) ) || ( this . _object === undefined && CoreTypes . isObjectArray ( this . _objects ) ) ) ; } private _isValidPrivateData ( ) { return this . _privateData === undefined || isPlainObject ( this . _privateData ) ; } }