/*
 * SDK Pullenti Lingvo, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software.
 * This class is generated using the converter Unisharping (www.unisharping.ru) from Pullenti C#.NET project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

const Utils = require("./../../unisharp/Utils");
const StringBuilder = require("./../../unisharp/StringBuilder");

const ReferentsEqualType = require("./../core/ReferentsEqualType");
const IntOntologyItem = require("./../core/IntOntologyItem");
const Termin = require("./../core/Termin");
const ReferentClass = require("./../metadata/ReferentClass");
const GoodMeta = require("./internal/GoodMeta");
const Referent = require("./../Referent");
const GoodAttributeReferent = require("./GoodAttributeReferent");

/**
 * Товар
 * 
 */
class GoodReferent extends Referent {
    
    constructor() {
        super(GoodReferent.OBJ_TYPENAME);
        this.instanceOf = GoodMeta.GLOBAL_META;
    }
    
    get attrs() {
        let res = new Array();
        for (const s of this.slots) {
            if (s.value instanceof GoodAttributeReferent) 
                res.push(Utils.as(s.value, GoodAttributeReferent));
        }
        return res;
    }
    
    toStringEx(shortVariant, lang = null, lev = 0) {
        let res = new StringBuilder();
        for (const a of this.attrs) {
            res.append(a.toStringEx(true, lang, lev)).append(" ");
        }
        return res.toString().trim();
    }
    
    canBeEquals(obj, typ = ReferentsEqualType.WITHINONETEXT) {
        return this === obj;
    }
    
    createOntologyItem() {
        let re = new IntOntologyItem(this);
        for (const s of this.slots) {
            if (s.typeName === GoodReferent.ATTR_ATTR) 
                re.termins.push(new Termin(s.value.toString()));
        }
        return re;
    }
    
    static static_constructor() {
        GoodReferent.OBJ_TYPENAME = "GOOD";
        GoodReferent.ATTR_ATTR = "ATTR";
    }
}


GoodReferent.static_constructor();

module.exports = GoodReferent