/*
 * 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# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

package com.pullenti.ner.vacance;

/**
 * Элемент вакансии
 */
public class VacanceItemReferent extends com.pullenti.ner.Referent {

    public VacanceItemReferent() {
        super(OBJ_TYPENAME);
        setInstanceOf(MetaVacance.GLOBALMETA);
    }

    /**
     * Имя типа сущности TypeName ("VACANCY")
     */
    public static final String OBJ_TYPENAME = "VACANCY";

    /**
     * Имя атрибута - тип элемента (см. VacanceItemType)
     */
    public static final String ATTR_TYPE = "TYPE";

    /**
     * Имя атрибута - значение
     */
    public static final String ATTR_VALUE = "VALUE";

    /**
     * Имя атрибута - ссылка на сущность
     */
    public static final String ATTR_REF = "REF";

    /**
     * Имя атрибута - признак снятия вакансии
     */
    public static final String ATTR_EXPIRED = "EXPIRED";

    public VacanceItemType getTyp() {
        String str = this.getStringValue(ATTR_TYPE);
        if (str == null) 
            return VacanceItemType.UNDEFINED;
        try {
            return (VacanceItemType)VacanceItemType.of(str);
        } catch (Exception ex3650) {
        }
        return VacanceItemType.UNDEFINED;
    }

    public VacanceItemType setTyp(VacanceItemType _value) {
        this.addSlot(ATTR_TYPE, _value.toString().toLowerCase(), true, 0);
        return _value;
    }


    public String getValue() {
        return this.getStringValue(ATTR_VALUE);
    }

    public String setValue(String _value) {
        this.addSlot(ATTR_VALUE, _value, true, 0);
        return _value;
    }


    public com.pullenti.ner.Referent getRef() {
        return (com.pullenti.ner.Referent)com.pullenti.unisharp.Utils.cast(this.getSlotValue(ATTR_REF), com.pullenti.ner.Referent.class);
    }

    public com.pullenti.ner.Referent setRef(com.pullenti.ner.Referent _value) {
        this.addSlot(ATTR_REF, _value, true, 0);
        return _value;
    }


    public boolean getExpired() {
        return com.pullenti.unisharp.Utils.stringsEq(this.getStringValue(ATTR_EXPIRED), "true");
    }

    public boolean setExpired(boolean _value) {
        this.addSlot(ATTR_EXPIRED, (_value ? "true" : null), true, 0);
        return _value;
    }


    @Override
    public String toStringEx(boolean shortVariant, com.pullenti.morph.MorphLang lang, int lev) {
        StringBuilder tmp = new StringBuilder();
        tmp.append(MetaVacance.TYPES.convertInnerValueToOuterValue(this.getStringValue(ATTR_TYPE), null)).append(": ");
        if (getValue() != null) 
            tmp.append(this.getValue());
        else if (getRef() != null) {
            tmp.append(this.getRef().toStringEx(shortVariant, lang, lev + 1));
            if (getTyp() == VacanceItemType.MONEY) {
                for (com.pullenti.ner.Slot s : getSlots()) {
                    if (com.pullenti.unisharp.Utils.stringsEq(s.getTypeName(), ATTR_REF) && s.getValue() != getRef()) {
                        tmp.append("-").append(((com.pullenti.ner.Referent)com.pullenti.unisharp.Utils.cast(s.getValue(), com.pullenti.ner.Referent.class)).toStringEx(shortVariant, lang, lev + 1));
                        break;
                    }
                }
            }
        }
        if (getExpired()) 
            tmp.append(" (не актуальна)");
        return tmp.toString();
    }
}
