<commit_before>package org.estatio.dom.lease;

import org.estatio.dom.lease.indexation.Indexable;
import org.estatio.dom.utils.MathUtils;

public enum IndexationMethod {
    BASE_INDEX {
        @Override
        public void doInitialze(Indexable term, Indexable previous) {
            if (previous != null) {
                // Base value is copied on initialisation, never updated
                term.setBaseValue(previous.getBaseValue());
                LeaseTermFrequency frequency = term.getFrequency();
                term.setBaseIndexStartDate(previous.getBaseIndexStartDate());
                if (term.getFrequency() != null) {
                    term.setNextIndexStartDate(frequency.nextDate(previous.getNextIndexStartDate()));
                    term.setEffectiveDate(frequency.nextDate(previous.getEffectiveDate()));
                }
            }
        }

        @Override
        public void doAlignBeforeIndexation(final Indexable term, final Indexable previous) {
            // Nothing to do before with base indexe methond
        }

        @Override
        public void doAlignAfterIndexation(final Indexable term, final Indexable previous) {
            term.setEffectiveIndexedValue(
                    MathUtils.max(
                            term.getBaseValue(),
                            term.getIndexedValue(),
                            previous == null ? null : previous.getEffectiveIndexedValue()));
        }
    },
    LAST_KNOWN_INDEX {
        @Override
        public void doInitialze(Indexable term, Indexable previous) {
            if (previous != null) {
                LeaseTermFrequency frequency = term.getFrequency();
                term.setBaseIndexStartDate(previous.getNextIndexStartDate());
                if (term.getFrequency() != null) {
                    term.setNextIndexStartDate(frequency.nextDate(previous.getNextIndexStartDate()));
                    term.setEffectiveDate(frequency.nextDate(previous.getEffectiveDate()));
                }
            }
        }

        @Override
        public void doAlignBeforeIndexation(Indexable term, Indexable previous) {<commit_msg>EST-552: Add indexation method that allows decrease<commit_after>package org.estatio.dom.lease;

import org.estatio.dom.lease.indexation.Indexable;
import org.estatio.dom.utils.MathUtils;

public enum IndexationMethod {
    BASE_INDEX {
        @Override
        public void doInitialze(Indexable term, Indexable previous) {
            if (previous != null) {
                // Base value is copied on initialisation, never updated
                term.setBaseValue(previous.getBaseValue());
                LeaseTermFrequency frequency = term.getFrequency();
                term.setBaseIndexStartDate(previous.getBaseIndexStartDate());
                if (term.getFrequency() != null) {
                    term.setNextIndexStartDate(frequency.nextDate(previous.getNextIndexStartDate()));
                    term.setEffectiveDate(frequency.nextDate(previous.getEffectiveDate()));
                }
            }
        }

        @Override
        public void doAlignBeforeIndexation(final Indexable term, final Indexable previous) {
            // Nothing to do before with base indexe methond
        }

        @Override
        public void doAlignAfterIndexation(final Indexable term, final Indexable previous) {
            term.setEffectiveIndexedValue(
                    MathUtils.max(
                            term.getBaseValue(),
                            term.getIndexedValue(),
                            previous == null ? null : previous.getEffectiveIndexedValue()));
        }
    },
    BASE_INDEX_ALLOW_DECREASE {
        @Override
        public void doInitialze(Indexable term, Indexable previous) {
            if (previous != null) {
                // Base value is copied on initialisation, never updated
                term.setBaseValue(previous.getBaseValue());
                LeaseTermFrequency frequency = term.getFrequency();
                term.setBaseIndexStartDate(previous.getBaseIndexStartDate());
                if (term.getFrequency() != null) {
                    term.setNextIndexStartDate(frequency.nextDate(previous.getNextIndexStartDate()));
                    term.setEffectiveDate(frequency.nextDate(previous.getEffectiveDate()));
                }
            }
        }

        @Override
        public void doAlignBeforeIndexation(final Indexable term, final Indexable previous) {
            // Nothing to do before with base indexe methond
        }

        @Override
        public void doAlignAfterIndexation(final Indexable term, final Indexable previous) {
            term.setEffectiveIndexedValue(
                    MathUtils.firstNonZero(
                            term.getIndexedValue(),
                            previous == null ? null : previous.getEffectiveIndexedValue(),
                            term.getBaseValue()));
        }
    },

    LAST_KNOWN_INDEX {
        @Override
        public void doInitialze(Indexable term, Indexable previous) {
            if (previous != null) {
                LeaseTermFrequency frequency = term.getFrequency();
                term.setBaseIndexStartDate(previous.getNextIndexStartDate());
                if (term.getFrequency() != null) {
                    term.setNextIndexStartDate(frequency.nextDate(previous.getNextIndexStartDate()));
                    term.setEffectiveDate(frequency.nextDate(previous.getEffectiveDate()));
                }
            }
        }

        @Override
        public void doAlignBeforeIndexation(Indexable term, Indexable previous) {
{'fraction_non_alphanumeric': 0.0819353699452587, 'fraction_numerical': 0.0005297545470598623, 'mean_word_length': 1.9515372589890567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3524579', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1312, 'n_words': 267}