/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { hashArray } from '@finos/legend-shared';
import { CORE_HASH_STRUCTURE } from '../../../../../../../graph/Core_HashUtils.js';
export class FlatDataDataType {
    _correspondingPrimitiveType;
    constructor(correspondingPrimitiveType) {
        this._correspondingPrimitiveType = correspondingPrimitiveType;
    }
}
export class FlatDataBoolean extends FlatDataDataType {
    trueString;
    falseString;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.FLAT_DATA_BOOLEAN,
            this.trueString ?? '',
            this.falseString ?? '',
        ]);
    }
}
export class FlatDataString extends FlatDataDataType {
    get hashCode() {
        return hashArray([CORE_HASH_STRUCTURE.FLAT_DATA_STRING]);
    }
}
export class FlatDataNumber extends FlatDataDataType {
    get hashCode() {
        return hashArray([CORE_HASH_STRUCTURE.FLAT_DATA_NUMBER]);
    }
}
export class FlatDataInteger extends FlatDataNumber {
    get hashCode() {
        return hashArray([CORE_HASH_STRUCTURE.FLAT_DATA_INTEGER]);
    }
}
export class FlatDataFloat extends FlatDataNumber {
    get hashCode() {
        return hashArray([CORE_HASH_STRUCTURE.FLAT_DATA_FLOAT]);
    }
}
export class FlatDataDecimal extends FlatDataNumber {
    get hashCode() {
        return hashArray([CORE_HASH_STRUCTURE.FLAT_DATA_DECIMAL]);
    }
}
export class FlatDataDate extends FlatDataDataType {
    dateFormat;
    timeZone;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.FLAT_DATA_DATE,
            this.dateFormat ? hashArray(this.dateFormat) : '',
            this.timeZone ?? '',
        ]);
    }
}
export class FlatDataDateTime extends FlatDataDate {
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.FLAT_DATA_DATE_TIME,
            this.dateFormat ? hashArray(this.dateFormat) : '',
            this.timeZone ?? '',
        ]);
    }
}
export class FlatDataStrictDate extends FlatDataDate {
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.FLAT_DATA_STRICT_DATE,
            this.dateFormat ? hashArray(this.dateFormat) : '',
            this.timeZone ?? '',
        ]);
    }
}
export class FlatDataRecordField {
    label;
    flatDataDataType;
    optional;
    address;
    constructor(label, flatDataDataType, optional) {
        this.label = label;
        this.flatDataDataType = flatDataDataType;
        this.optional = optional;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.FLAT_DATA_RECORD_FIELD,
            this.label,
            this.flatDataDataType,
            this.optional.toString(),
            this.address ?? '',
        ]);
    }
}
/**
 * NOTE: the fact that we have `fields` in `FlatDataRecordType` like this is misleading. What we should have and what Dave
 * also agreed on is that we will have another class `X` that is the super type of `RootFlatDataRecordType` and contains `fields`
 * instead of `FlatDataRecordType` as `FlatDataRecordType` is just a normal type like `FlatDataBoolean` that signals the driver
 * to look for a record type.
 *
 * As for `RootFlatDataRecordType` it should extends `X` so that we remain open for the possibility that flat data can have embedded
 * structure. Also `X` should not have name, as it can be embedded.
 */
export class FlatDataRecordType extends FlatDataDataType {
    fields = [];
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.FLAT_DATA_RECORD_TYPE,
            hashArray(this.fields),
        ]);
    }
}
export class RootFlatDataRecordType extends FlatDataRecordType {
    _OWNER;
    constructor(owner) {
        super();
        this._OWNER = owner;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.FLAT_DATA_ROOT_RECORD_TYPE,
            hashArray(this.fields),
        ]);
    }
}
//# sourceMappingURL=FlatDataDataType.js.map