/*
 * 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.decree;

/**
 * Сущность, представляющая ссылку на структурную часть НПА
 * 
 */
public class DecreePartReferent extends com.pullenti.ner.Referent {

    public DecreePartReferent() {
        super(OBJ_TYPENAME);
        setInstanceOf(com.pullenti.ner.decree.internal.MetaDecreePart.GLOBALMETA);
    }

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

    /**
     * Имя атрибута - владелец (DecreeReferent)
     */
    public static final String ATTR_OWNER = "OWNER";

    /**
     * Имя атрибута - тип локального владельца (ст.10 этого закона)
     */
    public static final String ATTR_LOCALTYP = "LOCALTYP";

    /**
     * Имя атрибута - часть документа (например, часть 1 Налогового кодекса)
     */
    public static final String ATTR_DOCPART = "DOCPART";

    /**
     * Имя атрибута - приложение (номер)
     */
    public static final String ATTR_APPENDIX = "APPENDIX";

    /**
     * Имя атрибута - приложение (название)
     */
    public static final String ATTR_APPENDIXNAME = "APPENDIXNAME";

    /**
     * Имя атрибута - приложение к приложению (номер)
     */
    public static final String ATTR_APPENDIX2 = "APPENDIX2";

    /**
     * Имя атрибута - приложение к приложению (название)
     */
    public static final String ATTR_APPENDIX2NAME = "APPENDIX2NAME";

    /**
     * Имя атрибута - раздел (номер)
     */
    public static final String ATTR_SECTION = "SECTION";

    /**
     * Имя атрибута - раздел (название)
     */
    public static final String ATTR_SECTIONNAME = "SECTIONNAME";

    /**
     * Имя атрибута - подраздел (номер)
     */
    public static final String ATTR_SUBSECTION = "SUBSECTION";

    /**
     * Имя атрибута - подраздел (название)
     */
    public static final String ATTR_SUBSECTIONNAME = "SUBSECTIONNAME";

    /**
     * Имя атрибута - глава (номер)
     */
    public static final String ATTR_CHAPTER = "CHAPTER";

    /**
     * Имя атрибута - глава (название)
     */
    public static final String ATTR_CHAPTERNAME = "CHAPTERNAME";

    /**
     * Имя атрибута - статья (номер)
     */
    public static final String ATTR_CLAUSE = "CLAUSE";

    /**
     * Имя атрибута - статья (название)
     */
    public static final String ATTR_CLAUSENAME = "CLAUSENAME";

    /**
     * Имя атрибута - параграф
     */
    public static final String ATTR_PARAGRAPH = "PARAGRAPH";

    /**
     * Имя атрибута - подпараграф
     */
    public static final String ATTR_SUBPARAGRAPH = "SUBPARAGRAPH";

    /**
     * Имя атрибута - часть статьи (не путать с частью документа!)
     */
    public static final String ATTR_PART = "PART";

    /**
     * Имя атрибута - пункт
     */
    public static final String ATTR_ITEM = "ITEM";

    /**
     * Имя атрибута - подпункт
     */
    public static final String ATTR_SUBITEM = "SUBITEM";

    /**
     * Имя атрибута - абзац
     */
    public static final String ATTR_INDENTION = "INDENTION";

    /**
     * Имя атрибута - подабзац
     */
    public static final String ATTR_SUBINDENTION = "SUBINDENTION";

    /**
     * Имя атрибута - преамбула
     */
    public static final String ATTR_PREAMBLE = "PREAMPLE";

    /**
     * Имя атрибута - примечание
     */
    public static final String ATTR_NOTICE = "NOTICE";

    /**
     * Имя атрибута - сноска
     */
    public static final String ATTR_FOOTNOTE = "FOOTNOTE";

    /**
     * Имя атрибута - формула
     */
    public static final String ATTR_FORMULA = "FORMULA";

    /**
     * Имя атрибута - форма
     */
    public static final String ATTR_FORM = "FORM";

    /**
     * Имя атрибута - наименование формы
     */
    public static final String ATTR_FORMNAME = "FORMNAME";

    /**
     * Имя атрибута - лист
     */
    public static final String ATTR_LIST = "LIST";

    /**
     * Имя атрибута - таблица
     */
    public static final String ATTR_TABLE = "TABLE";

    /**
     * Имя атрибута - наименование таблицы
     */
    public static final String ATTR_TABLENAME = "TABLENAME";

    /**
     * Тия атрибута - столбец таблицы
     */
    public static final String ATTR_TABLECOLUMN = "TABLECOLUMN";

    /**
     * Тия атрибута - строка таблицы
     */
    public static final String ATTR_TABLEROW = "TABLEROW";

    /**
     * Тия атрибута - графа таблицы (то ли строка, то ли столбец)
     */
    public static final String ATTR_TABLEITEM = "TABLEITEM";

    /**
     * Тия атрибута - прографка таблицы
     */
    public static final String ATTR_TABLESUBITEM = "TABLESUBITEM";

    /**
     * Имя атрибута - предложение
     */
    public static final String ATTR_SENTENCE = "SENTENCE";

    /**
     * Имя атрибута - наименование как элемент (например, ссылка "внести изменение в наименование ст.20 ...")
     */
    public static final String ATTR_NAMEASITEM = "NAMEASITEM";

    /**
     * Имя атрибута - подпрограмма
     */
    public static final String ATTR_SUBPROGRAM = "SUBPROGRAM";

    /**
     * Имя атрибута - имя подпрограммы
     */
    public static final String ATTR_SUBPROGRAMNAME = "SUBPROGRAMNAME";

    /**
     * Имя атрибута - дополнительное соглашение
     */
    public static final String ATTR_ADDAGREE = "ADDAGREE";

    /**
     * Это что-то непонятное
     */
    public static final String ATTR_FREETEXT = "FREETEXT";

    /**
     * Имя атрибута - страница
     */
    public static final String ATTR_PAGE = "PAGE";

    /**
     * Имя атрибута - дополнительное описание
     */
    public static final String ATTR_DESCRIPTION = "DESCRIPTION";

    @Override
    public String toStringEx(boolean shortVariant, com.pullenti.morph.MorphLang lang, int lev) {
        StringBuilder res = new StringBuilder();
        if (getFreetext() != null) 
            res.append(this.getFreetext());
        if (getNameAsItem() != null) 
            res.append(" наименование");
        if (getFormula() != null) 
            res.append(" формула ").append(this.getFormula());
        if (getSubIndention() != null) 
            res.append(" подабз.").append(this.getSubIndention());
        if (getIndention() != null) 
            res.append(" абз.").append(this.getIndention());
        if (getFootnote() != null) 
            res.append(" сноска ").append(this.getFootnote());
        if (getTableSubItem() != null) 
            res.append(" прографка \"").append(this.getTableSubItem()).append("\"");
        if (getTableItem() != null) {
            if (getTableItem().length() > 5) 
                res.append(" графа \"").append(this.getTableItem()).append("\"");
            else 
                res.append(" графа ").append(this.getTableItem());
        }
        if (getTableRow() != null) {
            if (getTableRow().length() > 5) 
                res.append(" строка \"").append(this.getTableRow()).append("\"");
            else 
                res.append(" строка ").append(this.getTableRow());
        }
        if (getTableColumn() != null) 
            res.append(" столбец ").append(this.getTableColumn());
        if (getTable() != null) {
            res.append(" таблица ").append(this.getTable());
            if (getTableName() != null) 
                res.append(" \"").append(this.getTableName()).append("\"");
        }
        if (getSentence() != null) 
            res.append(" предложение ").append(this.getSentence());
        if (getNotice() != null) 
            res.append(" прим.").append(this.getNotice());
        java.util.ArrayList<String> subs = this.getStringValues(ATTR_SUBITEM);
        if (subs.size() > 0) {
            for (String s : subs) {
                res.append(" пп.").append(s);
            }
        }
        if (getItem() != null) 
            res.append(" п.").append(this.getItem());
        if (getPart() != null) 
            res.append(" ч.").append(this.getPart());
        if (getPreamble() != null) 
            res.append(" преамб.").append((com.pullenti.unisharp.Utils.stringsEq(this.getPreamble(), "0") ? "" : this.getPreamble()));
        if (getList() != null) 
            res.append(" лист ").append(this.getList());
        if (getForm() != null) {
            res.append(" форма ").append(this.getForm());
            if (getFormName() != null) 
                res.append(" \"").append(this.getFormName()).append("\"");
        }
        if (getPage() != null) 
            res.append(" стр.").append(this.getPage());
        if (getClause() != null) {
            res.append(" ст.").append(this.getClause());
            if (getClauseName() != null) 
                res.append(" \"").append(this.getClauseName()).append("\"");
        }
        if (getSubParagraph() != null) 
            res.append(" подпар.").append(this.getSubParagraph());
        if (getParagraph() != null) 
            res.append(" пар.").append(this.getParagraph());
        if (getChapter() != null) {
            res.append(" гл.").append(this.getChapter());
            if (getChapterName() != null) 
                res.append(" \"").append(this.getChapterName()).append("\"");
        }
        if (getSubSection() != null) {
            res.append(" подразд.").append(this.getSubSection());
            if (getSubSectionName() != null) 
                res.append(" \"").append(this.getSubSectionName()).append("\"");
        }
        if (getSection() != null) {
            res.append(" разд.").append(this.getSection());
            if (getSectionName() != null) 
                res.append(" \"").append(this.getSectionName()).append("\"");
        }
        if (getDocPart() != null) 
            res.append(" док.часть ").append(this.getDocPart());
        String app = getAppendix();
        String app2 = getAppendix2();
        if (app2 == null) {
            if (com.pullenti.unisharp.Utils.stringsEq(app, "0")) 
                res.append(" приложение");
            else if (app != null) 
                res.append(" приложение ").append(app);
            if (app != null && getAppendixName() != null) 
                res.append(" \"").append(this.getAppendixName()).append("\"");
        }
        else {
            if (com.pullenti.unisharp.Utils.stringsEq(app2, "0")) 
                res.append(" приложение к");
            else if (app2 != null) 
                res.append(" приложение ").append(app2).append(" к");
            if (com.pullenti.unisharp.Utils.stringsEq(app, "0")) 
                res.append(" приложению");
            else if (app != null) 
                res.append(" приложению ").append(app);
        }
        if (getSubprogram() != null) {
            res.append(" подпрограмма ").append(this.getSubprogram());
            if (getSubprogramName() != null) 
                res.append(" \"").append(this.getSubprogramName()).append("\"");
        }
        if (getAddagree() != null) {
            if (com.pullenti.unisharp.Utils.stringsEq(getAddagree(), "0")) 
                res.append(" допсоглашение");
            else 
                res.append(" допсоглашение ").append(this.getAddagree());
        }
        if (((this.getOwner() != null || res.length() > 0)) && !shortVariant) {
            if (!shortVariant && getSubprogram() == null) {
                String s = getDescription();
                if (s != null) 
                    res.append(" (").append(s).append(")");
            }
            if (getOwner() != null && (lev < 20)) {
                if (res.length() > 0) 
                    res.append("; ");
                res.append(this.getOwner().toStringEx(shortVariant, lang, lev + 1));
            }
            else if (getLocalTyp() != null) 
                res.append("; ").append(com.pullenti.ner.core.MiscHelper.convertFirstCharUpperAndOtherLower(this.getLocalTyp()));
        }
        return res.toString().trim();
    }

    public String getDescription() {
        return this.getStringValue(ATTR_DESCRIPTION);
    }

    public String setDescription(String value) {
        if (value != null) 
            value = value.trim();
        if (com.pullenti.unisharp.Utils.isNullOrEmpty(value)) 
            value = null;
        this.addSlot(ATTR_DESCRIPTION, value, true, 0);
        return value;
    }


    public String getLocalTyp() {
        return this.getStringValue(ATTR_LOCALTYP);
    }

    public String setLocalTyp(String value) {
        this.addSlot(ATTR_LOCALTYP, value, true, 0);
        return value;
    }


    @Override
    public com.pullenti.ner.Slot addSlot(String attrName, Object attrValue, boolean clearOldValue, int statCount) {
        String _tag = null;
        if (attrValue instanceof com.pullenti.ner.decree.internal.PartToken.PartValue) {
            _tag = ((com.pullenti.ner.decree.internal.PartToken.PartValue)com.pullenti.unisharp.Utils.cast(attrValue, com.pullenti.ner.decree.internal.PartToken.PartValue.class)).getSourceValue();
            attrValue = ((com.pullenti.ner.decree.internal.PartToken.PartValue)com.pullenti.unisharp.Utils.cast(attrValue, com.pullenti.ner.decree.internal.PartToken.PartValue.class)).value;
        }
        com.pullenti.ner.Slot s = super.addSlot(attrName, attrValue, clearOldValue, statCount);
        if (_tag != null) 
            s.setTag(_tag);
        return s;
    }

    public String getClause() {
        return this.getStringValue(ATTR_CLAUSE);
    }

    public String setClause(String value) {
        this.addSlot(ATTR_CLAUSE, value, true, 0);
        return value;
    }


    public String getClauseName() {
        return this.getStringValue(ATTR_CLAUSENAME);
    }

    public String setClauseName(String value) {
        this.addSlot(ATTR_CLAUSENAME, value, true, 0);
        return value;
    }


    public String getPart() {
        return this.getStringValue(ATTR_PART);
    }

    public String setPart(String value) {
        this.addSlot(ATTR_PART, value, true, 0);
        return value;
    }


    public String getDocPart() {
        return this.getStringValue(ATTR_DOCPART);
    }

    public String setDocPart(String value) {
        this.addSlot(ATTR_DOCPART, value, true, 0);
        return value;
    }


    public String getSection() {
        return this.getStringValue(ATTR_SECTION);
    }

    public String setSection(String value) {
        this.addSlot(ATTR_SECTION, value, true, 0);
        return value;
    }


    public String getSectionName() {
        return this.getStringValue(ATTR_SECTIONNAME);
    }

    public String setSectionName(String value) {
        this.addSlot(ATTR_SECTIONNAME, value, true, 0);
        return value;
    }


    public String getSubSection() {
        return this.getStringValue(ATTR_SUBSECTION);
    }

    public String setSubSection(String value) {
        this.addSlot(ATTR_SUBSECTION, value, true, 0);
        return value;
    }


    public String getSubSectionName() {
        return this.getStringValue(ATTR_SUBSECTIONNAME);
    }

    public String setSubSectionName(String value) {
        this.addSlot(ATTR_SUBSECTIONNAME, value, true, 0);
        return value;
    }


    public String getAppendix() {
        return this.getStringValue(ATTR_APPENDIX);
    }

    public String setAppendix(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_APPENDIX, value, true, 0);
        return value;
    }


    public String getAppendixName() {
        return this.getStringValue(ATTR_APPENDIXNAME);
    }

    public String setAppendixName(String value) {
        this.addSlot(ATTR_APPENDIXNAME, value, true, 0);
        return value;
    }


    public String getAppendix2() {
        return this.getStringValue(ATTR_APPENDIX2);
    }

    public String setAppendix2(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_APPENDIX2, value, true, 0);
        return value;
    }


    public String getAppendix2Name() {
        return this.getStringValue(ATTR_APPENDIX2NAME);
    }

    public String setAppendix2Name(String value) {
        this.addSlot(ATTR_APPENDIX2NAME, value, true, 0);
        return value;
    }


    public String getChapter() {
        return this.getStringValue(ATTR_CHAPTER);
    }

    public String setChapter(String value) {
        this.addSlot(ATTR_CHAPTER, value, true, 0);
        return value;
    }


    public String getChapterName() {
        return this.getStringValue(ATTR_CHAPTERNAME);
    }

    public String setChapterName(String value) {
        this.addSlot(ATTR_CHAPTERNAME, value, true, 0);
        return value;
    }


    public String getParagraph() {
        return this.getStringValue(ATTR_PARAGRAPH);
    }

    public String setParagraph(String value) {
        this.addSlot(ATTR_PARAGRAPH, value, true, 0);
        return value;
    }


    public String getSubParagraph() {
        return this.getStringValue(ATTR_SUBPARAGRAPH);
    }

    public String setSubParagraph(String value) {
        this.addSlot(ATTR_SUBPARAGRAPH, value, true, 0);
        return value;
    }


    public String getItem() {
        return this.getStringValue(ATTR_ITEM);
    }

    public String setItem(String value) {
        this.addSlot(ATTR_ITEM, value, true, 0);
        return value;
    }


    public String getSubItem() {
        return this.getStringValue(ATTR_SUBITEM);
    }

    public String setSubItem(String value) {
        this.addSlot(ATTR_SUBITEM, value, true, 0);
        return value;
    }


    public String getIndention() {
        return this.getStringValue(ATTR_INDENTION);
    }

    public String setIndention(String value) {
        this.addSlot(ATTR_INDENTION, value, true, 0);
        return value;
    }


    public String getSubIndention() {
        return this.getStringValue(ATTR_SUBINDENTION);
    }

    public String setSubIndention(String value) {
        this.addSlot(ATTR_SUBINDENTION, value, true, 0);
        return value;
    }


    public String getPreamble() {
        return this.getStringValue(ATTR_PREAMBLE);
    }

    public String setPreamble(String value) {
        this.addSlot(ATTR_PREAMBLE, value, true, 0);
        return value;
    }


    public String getNameAsItem() {
        return this.getStringValue(ATTR_NAMEASITEM);
    }

    public String setNameAsItem(String value) {
        this.addSlot(ATTR_NAMEASITEM, value, true, 0);
        return value;
    }


    public String getFreetext() {
        return this.getStringValue(ATTR_FREETEXT);
    }

    public String setFreetext(String value) {
        this.addSlot(ATTR_FREETEXT, value, true, 0);
        return value;
    }


    public String getNotice() {
        return this.getStringValue(ATTR_NOTICE);
    }

    public String setNotice(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_NOTICE, value, true, 0);
        return value;
    }


    public String getFootnote() {
        return this.getStringValue(ATTR_FOOTNOTE);
    }

    public String setFootnote(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_FOOTNOTE, value, true, 0);
        return value;
    }


    public String getFormula() {
        return this.getStringValue(ATTR_FORMULA);
    }

    public String setFormula(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_FORMULA, value, true, 0);
        return value;
    }


    public String getForm() {
        return this.getStringValue(ATTR_FORM);
    }

    public String setForm(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_FORM, value, true, 0);
        return value;
    }


    public String getFormName() {
        return this.getStringValue(ATTR_FORMNAME);
    }

    public String setFormName(String value) {
        this.addSlot(ATTR_FORMNAME, value, true, 0);
        return value;
    }


    public String getList() {
        return this.getStringValue(ATTR_LIST);
    }

    public String setList(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_LIST, value, true, 0);
        return value;
    }


    public String getTable() {
        return this.getStringValue(ATTR_TABLE);
    }

    public String setTable(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_TABLE, value, true, 0);
        return value;
    }


    public String getTableName() {
        return this.getStringValue(ATTR_TABLENAME);
    }

    public String setTableName(String value) {
        this.addSlot(ATTR_TABLENAME, value, true, 0);
        return value;
    }


    public String getTableColumn() {
        return this.getStringValue(ATTR_TABLECOLUMN);
    }

    public String setTableColumn(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_TABLECOLUMN, value, true, 0);
        return value;
    }


    public String getTableRow() {
        return this.getStringValue(ATTR_TABLEROW);
    }

    public String setTableRow(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_TABLEROW, value, true, 0);
        return value;
    }


    public String getTableItem() {
        return this.getStringValue(ATTR_TABLEITEM);
    }

    public String setTableItem(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_TABLEITEM, value, true, 0);
        return value;
    }


    public String getTableSubItem() {
        return this.getStringValue(ATTR_TABLESUBITEM);
    }

    public String setTableSubItem(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_TABLESUBITEM, value, true, 0);
        return value;
    }


    public String getSentence() {
        return this.getStringValue(ATTR_SENTENCE);
    }

    public String setSentence(String value) {
        if (value != null && value.length() == 0) 
            value = "0";
        this.addSlot(ATTR_SENTENCE, value, true, 0);
        return value;
    }


    public String getPage() {
        return this.getStringValue(ATTR_PAGE);
    }

    public String setPage(String value) {
        this.addSlot(ATTR_PAGE, value, true, 0);
        return value;
    }


    public String getSubprogram() {
        return this.getStringValue(ATTR_SUBPROGRAM);
    }

    public String setSubprogram(String value) {
        this.addSlot(ATTR_SUBPROGRAM, value, true, 0);
        return value;
    }


    public String getSubprogramName() {
        return this.getStringValue(ATTR_SUBPROGRAMNAME);
    }

    public String setSubprogramName(String value) {
        this.addSlot(ATTR_SUBPROGRAMNAME, value, true, 0);
        return value;
    }


    public String getAddagree() {
        return this.getStringValue(ATTR_ADDAGREE);
    }

    public String setAddagree(String value) {
        this.addSlot(ATTR_ADDAGREE, value, true, 0);
        return value;
    }


    public DecreeReferent getOwner() {
        DecreeReferent res = (DecreeReferent)com.pullenti.unisharp.Utils.cast(this.getSlotValue(ATTR_OWNER), DecreeReferent.class);
        if (res == null) 
            return null;
        return res;
    }

    public DecreeReferent setOwner(DecreeReferent value) {
        this.addSlot(ATTR_OWNER, value, true, 0);
        if (value != null && getLocalTyp() != null) 
            setLocalTyp(null);
        return value;
    }


    @Override
    public com.pullenti.ner.Referent getParentReferent() {
        return getOwner();
    }


    @Override
    public void mergeSlots(com.pullenti.ner.Referent obj, boolean mergeStatistic) {
        super.mergeSlots(obj, mergeStatistic);
        if (getOwner() != null && getLocalTyp() != null) 
            setLocalTyp(null);
    }

    private int _getLevel(String typ) {
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_ADDAGREE) || com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SUBPROGRAM)) 
            return 0;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_DOCPART)) 
            return 1;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_APPENDIX) || com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_APPENDIXNAME)) 
            return 1;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_APPENDIX2) || com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_APPENDIX2NAME)) 
            return 2;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SUBPROGRAM) || com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SUBPROGRAMNAME)) 
            return 2;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SECTION) || com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SECTIONNAME)) 
            return 2;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SUBSECTION) || com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SUBSECTIONNAME)) 
            return 3;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_CHAPTER) || com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_CHAPTERNAME)) 
            return 4;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_PARAGRAPH)) 
            return 5;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SUBPARAGRAPH)) 
            return 6;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_PAGE)) 
            return 6;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_CLAUSE)) 
            return 7;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_FORM) || com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_FORMNAME)) 
            return 8;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_TABLE) || com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_TABLENAME)) 
            return 8;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_LIST)) 
            return 9;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_PREAMBLE)) 
            return 9;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_PART)) 
            return 9;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_NOTICE)) 
            return 10;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_ITEM)) 
            return 11;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_TABLEROW)) 
            return 11;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_TABLEITEM)) 
            return 11;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_TABLESUBITEM)) 
            return 12;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SUBITEM)) 
            return 12;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_INDENTION)) 
            return 13;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SUBINDENTION)) 
            return 14;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_SENTENCE)) 
            return 15;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_FORMULA)) 
            return 15;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_TABLECOLUMN)) 
            return 17;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_FOOTNOTE)) 
            return 17;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_NAMEASITEM)) 
            return 18;
        if (com.pullenti.unisharp.Utils.stringsEq(typ, ATTR_FREETEXT)) 
            return 19;
        return -1;
    }

    private boolean _hasLessLevelAttr(String typ) {
        int l = this._getLevel(typ);
        if (l < 0) 
            return false;
        for (com.pullenti.ner.Slot s : getSlots()) {
            int l1 = this._getLevel(s.getTypeName());
            if (l1 >= 0 && l1 > l) 
                return true;
        }
        return false;
    }

    public void addName(com.pullenti.ner.decree.internal.PartToken p, com.pullenti.ner.MetaToken val) {
        if (p == null || ((p.name == null && val == null))) 
            return;
        String typ = null;
        String typ1 = null;
        if (p.typ == com.pullenti.ner.decree.internal.PartToken.ItemType.APPENDIX) 
            typ = ATTR_APPENDIXNAME;
        else if (p.typ == com.pullenti.ner.decree.internal.PartToken.ItemType.APPENDIX2) 
            typ = ATTR_APPENDIX2NAME;
        else if (p.typ == com.pullenti.ner.decree.internal.PartToken.ItemType.SECTION) 
            typ = ATTR_SECTIONNAME;
        else if (p.typ == com.pullenti.ner.decree.internal.PartToken.ItemType.SUBSECTION) 
            typ = ATTR_SUBSECTIONNAME;
        else if (p.typ == com.pullenti.ner.decree.internal.PartToken.ItemType.SUBPROGRAM) 
            typ = ATTR_SUBPROGRAMNAME;
        else if (p.typ == com.pullenti.ner.decree.internal.PartToken.ItemType.CHAPTER) 
            typ = ATTR_CHAPTERNAME;
        else if (p.typ == com.pullenti.ner.decree.internal.PartToken.ItemType.CLAUSE) 
            typ = ATTR_CLAUSENAME;
        else if (p.typ == com.pullenti.ner.decree.internal.PartToken.ItemType.FORM) 
            typ = ATTR_FORMNAME;
        else if (p.typ == com.pullenti.ner.decree.internal.PartToken.ItemType.TABLE) 
            typ = ATTR_TABLENAME;
        else 
            return;
        if (val == null) 
            val = p.name;
        String nam = com.pullenti.ner.core.MiscHelper.getTextValueOfMetaToken(val, com.pullenti.ner.core.GetTextAttr.FIRSTNOUNGROUPTONOMINATIVE);
        com.pullenti.ner.Slot s = this.addSlot(typ, nam, true, 0);
        if (val != null) 
            s.setTag(val.getSourceText());
        if (p.values.size() == 0) 
            this.addSlot(typ.substring(0, 0 + typ.length() - 4), "0", true, 0);
    }

    public void addNamedLevelInfo(DecreePartReferent dp) {
        for (com.pullenti.ner.Slot s : dp.getSlots()) {
            if (this._getLevel(s.getTypeName()) > 7 || com.pullenti.unisharp.Utils.stringsEq(s.getTypeName(), ATTR_DOCPART)) {
            }
            else 
                this.addSlot(s.getTypeName(), s.getValue(), false, 0);
        }
    }

    private void _addSlot(DecreePartReferent dp, String attr) {
        com.pullenti.ner.Slot s = dp.findSlot(attr, null, true);
        if (s == null) 
            return;
        com.pullenti.ner.Slot ss = this.addSlot(attr, s.getValue(), true, 0);
        ss.setTag(s.getTag());
    }

    // Добавить информацию о вышележащих элементах
    public void addHighLevelInfo(DecreePartReferent dp) {
        if (dp.getAddagree() != null && getAddagree() == null) 
            setAddagree(dp.getAddagree());
        else if (com.pullenti.unisharp.Utils.stringsNe(dp.getAddagree(), getAddagree())) 
            return;
        if (dp.getAppendix() != null && getAppendix() == null) {
            this._addSlot(dp, ATTR_APPENDIX);
            this._addSlot(dp, ATTR_APPENDIXNAME);
        }
        else if (com.pullenti.unisharp.Utils.stringsNe(getAppendix(), dp.getAppendix())) 
            return;
        else if (com.pullenti.unisharp.Utils.stringsEq(getAppendix(), "0") && com.pullenti.unisharp.Utils.stringsNe(getAppendixName(), dp.getAppendixName())) 
            return;
        if (dp.getAppendix2() != null && getAppendix2() == null) {
            this._addSlot(dp, ATTR_APPENDIX2);
            this._addSlot(dp, ATTR_APPENDIX2NAME);
        }
        else if (com.pullenti.unisharp.Utils.stringsNe(getAppendix2(), dp.getAppendix2())) 
            return;
        else if (com.pullenti.unisharp.Utils.stringsEq(getAppendix2(), "0") && com.pullenti.unisharp.Utils.stringsNe(getAppendix2Name(), dp.getAppendix2Name())) 
            return;
        if (dp.getSubprogram() != null && getSubprogram() == null) {
            this._addSlot(dp, ATTR_SUBPROGRAM);
            this._addSlot(dp, ATTR_SUBPROGRAMNAME);
        }
        else if (com.pullenti.unisharp.Utils.stringsNe(getSubprogram(), dp.getSubprogram())) 
            return;
        if (com.pullenti.unisharp.Utils.stringsNe(getSubprogramName(), dp.getSubprogramName())) 
            return;
        if (dp.getDocPart() != null && getDocPart() == null) 
            this._addSlot(dp, ATTR_DOCPART);
        else if (com.pullenti.unisharp.Utils.stringsNe(getDocPart(), dp.getDocPart())) {
            if (dp.getDocPart() != null) 
                return;
        }
        if (dp.getSection() != null && getSection() == null && this._hasLessLevelAttr(ATTR_SECTION)) {
            this._addSlot(dp, ATTR_SECTION);
            this._addSlot(dp, ATTR_SECTIONNAME);
        }
        else if (com.pullenti.unisharp.Utils.stringsNe(getSection(), dp.getSection())) 
            return;
        else if (com.pullenti.unisharp.Utils.stringsEq(getSection(), "0") && com.pullenti.unisharp.Utils.stringsNe(getSectionName(), dp.getSectionName())) 
            return;
        if (dp.getSubSection() != null && getSubSection() == null && this._hasLessLevelAttr(ATTR_SUBSECTION)) {
            this._addSlot(dp, ATTR_SUBSECTION);
            this._addSlot(dp, ATTR_SUBSECTIONNAME);
        }
        else if (com.pullenti.unisharp.Utils.stringsNe(getSubSection(), dp.getSubSection())) 
            return;
        else if (com.pullenti.unisharp.Utils.stringsEq(getSubSection(), "0") && com.pullenti.unisharp.Utils.stringsNe(getSubSectionName(), dp.getSubSectionName())) 
            return;
        if (dp.getChapter() != null && getChapter() == null && this._hasLessLevelAttr(ATTR_CHAPTER)) {
            this._addSlot(dp, ATTR_CHAPTER);
            this._addSlot(dp, ATTR_CHAPTERNAME);
        }
        else if (com.pullenti.unisharp.Utils.stringsNe(dp.getChapter(), getChapter())) 
            return;
        else if (com.pullenti.unisharp.Utils.stringsEq(dp.getChapter(), "0") && com.pullenti.unisharp.Utils.stringsNe(dp.getChapterName(), getChapterName())) 
            return;
        if (dp.getParagraph() != null && getParagraph() == null && this._hasLessLevelAttr(ATTR_PARAGRAPH)) 
            this._addSlot(dp, ATTR_PARAGRAPH);
        else if (com.pullenti.unisharp.Utils.stringsNe(getParagraph(), dp.getParagraph())) 
            return;
        if (dp.getSubParagraph() != null && getSubParagraph() == null && this._hasLessLevelAttr(ATTR_SUBPARAGRAPH)) 
            setSubParagraph(dp.getSubParagraph());
        else if (com.pullenti.unisharp.Utils.stringsNe(getSubParagraph(), dp.getSubParagraph())) 
            return;
        if (dp.getClause() != null && getClause() == null && ((this._hasLessLevelAttr(ATTR_CLAUSE) || (this.getSlots().size() < 2)))) 
            this._addSlot(dp, ATTR_CLAUSE);
        else if (com.pullenti.unisharp.Utils.stringsNe(dp.getClause(), getClause())) 
            return;
        if (dp.getPart() != null && getPart() == null && this._hasLessLevelAttr(ATTR_PART)) 
            this._addSlot(dp, ATTR_PART);
        else if (com.pullenti.unisharp.Utils.stringsNe(dp.getPart(), getPart())) 
            return;
        if (dp.getForm() != null && getForm() == null && this._hasLessLevelAttr(ATTR_FORM)) {
            this._addSlot(dp, ATTR_FORM);
            this._addSlot(dp, ATTR_FORMNAME);
        }
        if (dp.getTable() != null && getTable() == null && this._hasLessLevelAttr(ATTR_TABLE)) {
            this._addSlot(dp, ATTR_TABLE);
            this._addSlot(dp, ATTR_TABLENAME);
        }
        if (dp.getList() != null && getList() == null && this._hasLessLevelAttr(ATTR_LIST)) 
            this._addSlot(dp, ATTR_LIST);
        if (dp.getItem() != null && getItem() == null && this._hasLessLevelAttr(ATTR_ITEM)) 
            this._addSlot(dp, ATTR_ITEM);
        else if (com.pullenti.unisharp.Utils.stringsNe(dp.getItem(), getItem())) {
            if ((dp.getTableItem() != null && dp.getItem() == null && getTableRow() == null) && getItem() != null) {
                setTableRow(this.getItem());
                setItem(null);
            }
            else if ((dp.getItem() != null && getItem() == null && getTableRow() == null) && ((dp.getTableItem() != null || this.getTableItem() != null))) 
                setTableRow(dp.getItem());
            else 
                return;
        }
        if (dp.getTableRow() != null && getTableRow() == null && ((this._hasLessLevelAttr(ATTR_TABLEROW) || this.getTableItem() != null))) 
            this._addSlot(dp, ATTR_TABLEROW);
        if (dp.getSubItem() != null && getSubItem() == null && this._hasLessLevelAttr(ATTR_SUBITEM)) 
            this._addSlot(dp, ATTR_SUBITEM);
        else if (com.pullenti.unisharp.Utils.stringsNe(dp.getSubItem(), getSubItem())) 
            return;
        if (dp.getNotice() != null && getNotice() == null && this._hasLessLevelAttr(ATTR_NOTICE)) 
            this._addSlot(dp, ATTR_NOTICE);
        else if (com.pullenti.unisharp.Utils.stringsNe(dp.getNotice(), getNotice())) 
            return;
        if (dp.getPreamble() != null && getPreamble() == null) 
            this._addSlot(dp, ATTR_PREAMBLE);
        if (dp.getIndention() != null && getIndention() == null && this._hasLessLevelAttr(ATTR_INDENTION)) 
            this._addSlot(dp, ATTR_INDENTION);
        if (dp.getTableColumn() != null && getTableColumn() == null && this._hasLessLevelAttr(ATTR_TABLECOLUMN)) 
            this._addSlot(dp, ATTR_TABLECOLUMN);
        if (dp.getTableItem() != null && getTableItem() == null && ((this._hasLessLevelAttr(ATTR_TABLEITEM) || this.getTableRow() != null || this.getItem() != null))) 
            this._addSlot(dp, ATTR_TABLEITEM);
        if (dp.getTableSubItem() != null && getTableSubItem() == null && ((this._hasLessLevelAttr(ATTR_TABLESUBITEM) || this.getTableRow() != null || this.getItem() != null))) 
            this._addSlot(dp, ATTR_TABLESUBITEM);
    }

    // Проверить, что все элементы находятся на более низком уровне, чем у аргумента
    public boolean isAllItemsLessLevel(com.pullenti.ner.Referent upperParts, boolean ignoreEquals) {
        if (upperParts instanceof DecreeReferent) 
            return true;
        int maxLev = 0;
        String maxTyp = null;
        for (com.pullenti.ner.Slot s : getSlots()) {
            int l = this._getLevel(s.getTypeName());
            if (l > maxLev) {
                maxLev = l;
                maxTyp = s.getTypeName();
            }
        }
        for (com.pullenti.ner.Slot s : getSlots()) {
            int l = this._getLevel(s.getTypeName());
            if (l < 0) 
                continue;
            if (upperParts.findSlot(s.getTypeName(), null, true) != null) {
                if (ignoreEquals) {
                    if (l == maxLev) 
                        continue;
                }
                if (upperParts.findSlot(s.getTypeName(), s.getValue(), true) == null) 
                    return false;
                continue;
            }
            for (com.pullenti.ner.Slot ss : upperParts.getSlots()) {
                int ll = this._getLevel(ss.getTypeName());
                if (ll >= l) 
                    return false;
            }
        }
        return true;
    }

    // удалить все значения уровня больше или равно
    public void removeSlots(com.pullenti.ner.decree.internal.PartToken.ItemType typ) {
        int l0 = this._getLevel(com.pullenti.ner.decree.internal.PartToken._getAttrNameByTyp(typ));
        if (l0 <= 0) 
            return;
        for (int i = getSlots().size() - 1; i >= 0; i--) {
            int l = this._getLevel(this.getSlots().get(i).getTypeName());
            if (l >= l0) {
                if (((typ == com.pullenti.ner.decree.internal.PartToken.ItemType.TABLEITEM || typ == com.pullenti.ner.decree.internal.PartToken.ItemType.TABLESUBITEM)) && ((com.pullenti.unisharp.Utils.stringsEq(this.getSlots().get(i).getTypeName(), "TABLEROW") || com.pullenti.unisharp.Utils.stringsEq(this.getSlots().get(i).getTypeName(), "ITEM")))) {
                }
                else if (((typ == com.pullenti.ner.decree.internal.PartToken.ItemType.TABLEROW || typ == com.pullenti.ner.decree.internal.PartToken.ItemType.ITEM)) && com.pullenti.unisharp.Utils.stringsEq(this.getSlots().get(i).getTypeName(), "TABLEITEM")) {
                }
                else 
                    getSlots().remove(i);
            }
        }
    }

    public boolean isAllItemsOverThisLevel(com.pullenti.ner.decree.internal.PartToken.ItemType typ) {
        int l0 = this._getLevel(com.pullenti.ner.decree.internal.PartToken._getAttrNameByTyp(typ));
        if (l0 <= 0) 
            return false;
        for (com.pullenti.ner.Slot s : getSlots()) {
            int l = this._getLevel(s.getTypeName());
            if (l <= 0) 
                continue;
            if (l >= l0) {
                if (typ == com.pullenti.ner.decree.internal.PartToken.ItemType.FOOTNOTE && l > l0) {
                }
                else 
                    return false;
            }
        }
        return true;
    }

    public int getMinLevel() {
        int min = 0;
        for (com.pullenti.ner.Slot s : getSlots()) {
            int l = this._getLevel(s.getTypeName());
            if (l <= 0) 
                continue;
            if (min == 0) 
                min = l;
            else if (min > l) 
                min = l;
        }
        return min;
    }

    @Override
    public boolean canBeEquals(com.pullenti.ner.Referent obj, com.pullenti.ner.core.ReferentsEqualType typ) {
        boolean b = this._CanBeEquals(obj, typ, false);
        return b;
    }

    private boolean _CanBeEquals(com.pullenti.ner.Referent obj, com.pullenti.ner.core.ReferentsEqualType typ, boolean ignoreGeo) {
        DecreePartReferent dr = (DecreePartReferent)com.pullenti.unisharp.Utils.cast(obj, DecreePartReferent.class);
        if (dr == null) 
            return false;
        if (getOwner() != null && dr.getOwner() != null) {
            if (getOwner() != dr.getOwner()) 
                return false;
        }
        else if (typ == com.pullenti.ner.core.ReferentsEqualType.DIFFERENTTEXTS) 
            return false;
        else {
            String ty1 = (getOwner() == null ? getLocalTyp() : getOwner().getTyp());
            String ty2 = (dr.getOwner() == null ? dr.getLocalTyp() : dr.getOwner().getTyp());
            if (com.pullenti.unisharp.Utils.stringsNe(ty1, ty2)) {
                ty1 = (this.getOwner() == null ? this.getLocalTyp() : this.getOwner().getTyp0());
                ty2 = (dr.getOwner() == null ? dr.getLocalTyp() : dr.getOwner().getTyp0());
                if (com.pullenti.unisharp.Utils.stringsNe(ty1, ty2)) 
                    return false;
            }
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getClause(), dr.getClause())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getClause() == null || dr.getClause() == null))) {
            }
            else 
                return false;
        }
        else if (com.pullenti.unisharp.Utils.stringsEq(getClause(), "0") && com.pullenti.unisharp.Utils.stringsNe(getClauseName(), dr.getClauseName())) 
            return false;
        if (com.pullenti.unisharp.Utils.stringsNe(getPart(), dr.getPart())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getPart() == null || dr.getPart() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getParagraph(), dr.getParagraph())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getParagraph() == null || dr.getParagraph() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getSubParagraph(), dr.getSubParagraph())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getSubParagraph() == null || dr.getSubParagraph() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getNameAsItem(), dr.getNameAsItem())) 
            return false;
        if (com.pullenti.unisharp.Utils.stringsNe(getItem(), dr.getItem())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getItem() == null || dr.getItem() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getFreetext(), dr.getFreetext())) 
            return false;
        if (com.pullenti.unisharp.Utils.stringsNe(getSubItem(), dr.getSubItem())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getSubItem() == null || dr.getSubItem() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getNotice(), dr.getNotice())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getNotice() == null || dr.getNotice() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getFootnote(), dr.getFootnote())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getFootnote() == null || dr.getFootnote() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getForm(), dr.getForm())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getForm() == null || dr.getForm() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsEq(getForm(), "0") && com.pullenti.unisharp.Utils.stringsNe(getFormName(), dr.getFormName())) 
            return false;
        if (com.pullenti.unisharp.Utils.stringsNe(getList(), dr.getList())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getList() == null || dr.getList() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getTable(), dr.getTable())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getTable() == null || dr.getTable() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsEq(getTable(), "0") && com.pullenti.unisharp.Utils.stringsNe(getTableName(), dr.getTableName())) 
            return false;
        if (com.pullenti.unisharp.Utils.stringsNe(getTableColumn(), dr.getTableColumn())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getTableColumn() == null || dr.getTableColumn() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getTableRow(), dr.getTableRow())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getTableRow() == null || dr.getTableRow() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getTableItem(), dr.getTableItem())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getTableItem() == null || dr.getTableItem() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getTableSubItem(), dr.getTableSubItem())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getTableSubItem() == null || dr.getTableSubItem() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getFormula(), dr.getFormula())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getFormula() == null || dr.getFormula() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getSentence(), dr.getSentence())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getSentence() == null || dr.getSentence() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getIndention(), dr.getIndention())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getIndention() == null || dr.getIndention() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getSubIndention(), dr.getSubIndention())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getSubIndention() == null || dr.getSubIndention() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getAppendix(), dr.getAppendix())) {
            if (getAppendix() != null && dr.getAppendix() != null) 
                return false;
            if (getClause() == null && getParagraph() == null && getItem() == null) 
                return false;
            if (typ != com.pullenti.ner.core.ReferentsEqualType.FORMERGING) 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getAppendixName(), dr.getAppendixName()) && getAppendixName() != null && dr.getAppendixName() != null) 
            return false;
        if (com.pullenti.unisharp.Utils.stringsNe(getAppendix2(), dr.getAppendix2())) {
            if (getAppendix2() != null && dr.getAppendix2() != null) 
                return false;
            if (getClause() == null && getParagraph() == null && getItem() == null) 
                return false;
            if (typ != com.pullenti.ner.core.ReferentsEqualType.FORMERGING) 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getAppendix2Name(), dr.getAppendix2Name())) 
            return false;
        if (com.pullenti.unisharp.Utils.stringsNe(getChapter(), dr.getChapter())) {
            if (getChapter() != null && dr.getChapter() != null) 
                return false;
            if (getClause() == null && getParagraph() == null && getItem() == null) 
                return false;
            if (typ != com.pullenti.ner.core.ReferentsEqualType.FORMERGING) 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsEq(getChapter(), "0") && com.pullenti.unisharp.Utils.stringsNe(getChapterName(), dr.getChapterName())) 
            return false;
        if (com.pullenti.unisharp.Utils.stringsNe(getSection(), dr.getSection())) {
            if (getSection() != null && dr.getSection() != null) 
                return false;
            if ((getClause() == null && getParagraph() == null && getItem() == null) && getSubSection() == null) 
                return false;
            if (typ != com.pullenti.ner.core.ReferentsEqualType.FORMERGING) 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsEq(getSection(), "0") && com.pullenti.unisharp.Utils.stringsNe(getSectionName(), dr.getSectionName())) 
            return false;
        if (com.pullenti.unisharp.Utils.stringsNe(getSubSection(), dr.getSubSection())) {
            if (getSubSection() != null && dr.getSubSection() != null) 
                return false;
            if (getClause() == null && getParagraph() == null && getItem() == null) 
                return false;
            if (typ != com.pullenti.ner.core.ReferentsEqualType.FORMERGING) 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsEq(getSubSection(), "0") && com.pullenti.unisharp.Utils.stringsNe(getSubSectionName(), dr.getSubSectionName())) 
            return false;
        if (getSubprogram() != null || dr.getSubprogram() != null) {
            if (com.pullenti.unisharp.Utils.stringsNe(getSubprogram(), dr.getSubprogram())) 
                return false;
            if (com.pullenti.unisharp.Utils.stringsNe(getSubprogramName(), dr.getSubprogramName())) 
                return false;
            return true;
        }
        if (getAddagree() != null || dr.getAddagree() != null) {
            if (com.pullenti.unisharp.Utils.stringsNe(getAddagree(), dr.getAddagree())) 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getDocPart(), dr.getDocPart())) {
            if (typ == com.pullenti.ner.core.ReferentsEqualType.FORMERGING && ((this.getDocPart() == null || dr.getDocPart() == null))) {
            }
            else 
                return false;
        }
        if (com.pullenti.unisharp.Utils.stringsNe(getPage(), dr.getPage())) 
            return false;
        return true;
    }

    public static DecreePartReferent createRangeReferent(DecreePartReferent min, DecreePartReferent max) {
        DecreePartReferent res = (DecreePartReferent)com.pullenti.unisharp.Utils.cast(min.clone(), DecreePartReferent.class);
        int cou = 0;
        for (com.pullenti.ner.Slot s : res.getSlots()) {
            com.pullenti.ner.Slot ss = max.findSlot(s.getTypeName(), null, true);
            if (ss == null) 
                return null;
            if (ss.getValue() == s.getValue()) 
                continue;
            if (max.findSlot(s.getTypeName(), s.getValue(), true) != null) 
                continue;
            if ((++cou) > 1) 
                return null;
            res.uploadSlot(s, (s.getValue().toString() + "-" + ss.getValue()));
        }
        if (cou != 1) 
            return null;
        return res;
    }

    public static DecreePartReferent _new1460(DecreeReferent _arg1) {
        DecreePartReferent res = new DecreePartReferent();
        res.setOwner(_arg1);
        return res;
    }
}
