import { IotizeConfigModel } from './model/iotize-config-model';
/**
 * Utility class to create iotize config model from XML or JSON file
 */
export class IotizeConfigFactory {
    /**
     * Create IotizeConfigModel from a XML string
     * @param xml
     */
    static fromXML(xml) {
        throw new Error(`Add import to @iotize/tap/config/iotize-studio/parser/xml to create configuration model from XML file`);
    }
    /**
     * Create IotizeConfigModel from a JSON string
     * @param json
     */
    static fromJson(json) {
        return new IotizeConfigModel(JSON.parse(json));
    }
    /**
     * Build and IotizeConfigModel
     * Input can either be
     * - A json string
     * - A XML string
     * - A JSON Object
     *
     * TODO create test
     * @param data
     */
    static create(data) {
        if (typeof data === 'string') {
            data.trim();
            if (data.length === 0) {
                throw new Error('Cannot create configuration from empty data');
            }
            if (data[0] === '{') {
                return IotizeConfigFactory.fromJson(data);
            }
            else {
                return IotizeConfigFactory.fromXML(data);
            }
        }
        else {
            return new IotizeConfigModel(data);
        }
    }
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW90aXplLWNvbmZpZy1mYWN0b3J5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vY29uZmlnL2lvdGl6ZS1zdHVkaW8vc3JjL2xpYi9pb3RpemUtY29uZmlnLWZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFaEU7O0dBRUc7QUFDSCxNQUFNLE9BQU8sbUJBQW1CO0lBQzlCOzs7T0FHRztJQUNILE1BQU0sQ0FBQyxPQUFPLENBQUMsR0FBVztRQUN4QixNQUFNLElBQUksS0FBSyxDQUNiLHVHQUF1RyxDQUN4RyxDQUFDO0lBQ0osQ0FBQztJQUVEOzs7T0FHRztJQUNILE1BQU0sQ0FBQyxRQUFRLENBQUMsSUFBWTtRQUMxQixPQUFPLElBQUksaUJBQWlCLENBQUMsSUF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