/**
 * 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 { InstanceValue } from './InstanceValue.js';
import { hashArray } from '@finos/legend-shared';
import { CORE_HASH_STRUCTURE } from '../../../Core_HashUtils.js';
import { Multiplicity } from '../packageableElements/domain/Multiplicity.js';
export class GraphFetchTree {
    subTrees = [];
    subTypeTrees = [];
    get isEmpty() {
        return !this.subTrees.length;
    }
}
export class RootGraphFetchTree extends GraphFetchTree {
    class;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.ROOT_GRAPH_FETCH_TREE,
            hashArray(this.subTrees),
            hashArray(this.subTypeTrees),
            this.class.valueForSerialization ?? '',
        ]);
    }
    constructor(_class) {
        super();
        this.class = _class;
    }
}
export class PropertyGraphFetchTree extends GraphFetchTree {
    property;
    alias;
    parameters = []; //TODO
    subType;
    constructor(property, subType) {
        super();
        this.property = property;
        this.subType = subType;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.PROPERTY_GRAPH_FETCH_TREE,
            hashArray(this.subTrees),
            this.property.ownerReference.valueForSerialization ?? '',
            this.alias ?? '',
            hashArray(this.parameters),
            this.subType?.valueForSerialization ?? '',
        ]);
    }
}
export class SubTypeGraphFetchTree extends GraphFetchTree {
    subTypeClass;
    constructor(subTypeClass) {
        super();
        this.subTypeClass = subTypeClass;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.SUBTYPE_GRAPH_FETCH_TREE,
            hashArray(this.subTrees),
            this.subTypeClass.valueForSerialization ?? '',
        ]);
    }
}
export class GraphFetchTreeInstanceValue extends InstanceValue {
    values = [];
    constructor() {
        super(Multiplicity.ONE);
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.ROOT_GRAPH_FETCH_TREE_INSTANCE_VALUE,
            this.genericType?.ownerReference.valueForSerialization ?? '',
            this.multiplicity,
            hashArray(this.values),
        ]);
    }
    accept_ValueSpecificationVisitor(visitor) {
        return visitor.visit_GraphFetchTreeInstanceValue(this);
    }
}
//# sourceMappingURL=GraphFetchTree.js.map