blob: c1840e3daf1d52003b040b2f3c3326b85b3859ed [file] [log] [blame]
import { DatasourceType } from './types/Datasource';
export default class DatasourceKey {
readonly id: number;
readonly type: DatasourceType;
constructor(key: string) {
const [idStr, typeStr] = key.split('__');
this.id = parseInt(idStr, 10);
this.type = typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid;
}
public toString() {
return `${this.id}__${this.type}`;
}
public toObject() {
return {
id: this.id,
type: this.type,
};
}
}