import { AnnotationConfig } from '../types' ; import { Strings } from '../utils' ; import { ODataAnnotatable } from './annotation' ; import { ODataSchema } from './schema' ; export class ODataSchemaElement extends ODataAnnotatable { name : string ; schema : ODataSchema ; constructor ( config , schema ) { super ( config ) ; this . schema = schema ; this . name = config . name ; } get api ( ) { return this . schema . api ; } param term returns titleize ( term ? ) { return ( term && this . annotatedValue ( term ) ) || Strings . titleCase ( this . name ) ; } param alias returns type ( { alias = false } = { } ) { return `${ alias ? this . schema . alias : this . schema . namespace }.${ this . name }` ; } param type returns isTypeOf ( type ) { var names = [ `${ this . schema . namespace }.${ this . name }` ] ; if ( this . schema . alias ) names . push ( `${ this . schema . alias }.${ this . name }` ) ; return names . indexOf ( type ) !== - 1 ; } param type returns isSubtypeOf ( schema ) { if ( this . isTypeOf ( schema . type ( ) ) ) return true ; return false ; } }