import { P_INDEX_COLUMN , IndexColumnInterface } from '../../../../typings' ; import { isDefined } from '../../../../shared/utils' ; import { IndexColumnModelInterface , } from './typings' ; /**
 * Index specification of a column.
 */ export class IndexColumn implements IndexColumnModelInterface { column ? : string ; length ? : number ; sort ? : string ; param json static fromDef ( json ) { if ( json . id === 'P_INDEX_COLUMN' ) { return IndexColumn . fromObject ( json . def ) ; } throw new TypeError ( `Unknown json id to build index column from: ${ json . id }` ) ; } param json static fromObject ( json ) { const indexColumn = new IndexColumn ( ) ; indexColumn . column = json . column ; if ( json . length ) { indexColumn . length = json . length ; } if ( json . sort ) { indexColumn . sort = json . sort ; } return indexColumn ; } /**
     * JSON casting of this object calls this method.
     */ toJSON ( ) { const json = { column : this . column , } ; if ( isDefined ( this . length ) ) { json . length = this . length ; } if ( isDefined ( this . sort ) ) { json . sort = this . sort ; } return json ; } /**
     * Create a deep clone of this model.
     */ clone ( ) { const indexColumn = new IndexColumn ( ) ; indexColumn . column = this . column ; if ( isDefined ( this . length ) ) { indexColumn . length = this . length ; } if ( isDefined ( this . sort ) ) { indexColumn . sort = this . sort ; } return indexColumn ; } }