<commit_before>package org.sanelib.eboss.core.exceptions;

import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Component
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class ProcessError {

    private final List<ErrorLine> errors = new ArrayList<>();

    public void addError(String template){
        this.errors.add(new ErrorLine(template, new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
    }

    public void addError(String template, String fieldName, String labelName){
        this.errors.add(new ErrorLine(template, Collections.singletonList(fieldName), Collections.singletonList(labelName), new ArrayList<>()));
    }

    public void addError(String template, String fieldName, String labelName, String value){
        this.errors.add(new ErrorLine(template, Collections.singletonList(fieldName), Collections.singletonList(labelName), Collections.singletonList(value)));
    }

    public List<ErrorLine> getErrors() {
        return errors;
    }

    public boolean isValid() {
        return this.errors.isEmpty();
    }

    public static class ErrorLine {

        private final List<String> fieldNames = new ArrayList<>();
        private final List<String> termNames = new ArrayList<>();
        private final List<String> values = new ArrayList<>();
        private final String template; //msg key

        /**
         *
         * @param template		Template of message.
         * @param fieldNames	Filed names of submitted form
         * @param termNames		Form label names
         * @param values		Direct values from form
         */
        public ErrorLine(String template, List<String> fieldNames, List<String> termNames, List<String> values) {
            this.template = template;
            this.fieldNames.addAll(fieldNames);
            this.termNames.addAll(termNames);
            this.values.addAll(values);
        }

        public String getTemplate() {
            return this.template;
        }

        public List<String> getFieldNames() {
            return this.fieldNames;
        }

        public List<String> getTermNames() {
            return this.termNames;
        }

        public List<String> getValues() {
            return this.values;
        }
    }
}<commit_msg>Adding helper method in ProcessError for enhancement.<commit_after>package org.sanelib.eboss.core.exceptions;

import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Component
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class ProcessError {

    private final List<ErrorLine> errors = new ArrayList<>();

    public void addError(String template){
        this.errors.add(new ErrorLine(template, new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
    }

    public void addError(String template, String fieldName, String labelName){
        this.errors.add(new ErrorLine(template, Collections.singletonList(fieldName), Collections.singletonList(labelName), new ArrayList<>()));
    }

    public void addError(String template, String fieldName, String labelName, String value){
        this.errors.add(new ErrorLine(template, Collections.singletonList(fieldName), Collections.singletonList(labelName), Collections.singletonList(value)));
    }

    public void addError(String template, String fieldName, List<String> labelNames, String value){
        this.errors.add(new ErrorLine(template, Collections.singletonList(fieldName), labelNames, Collections.singletonList(value)));
    }

    public List<ErrorLine> getErrors() {
        return errors;
    }

    public boolean isValid() {
        return this.errors.isEmpty();
    }

    public static class ErrorLine {

        private final List<String> fieldNames = new ArrayList<>();
        private final List<String> termNames = new ArrayList<>();
        private final List<String> values = new ArrayList<>();
        private final String template; //msg key

        /**
         *
         * @param template		Template of message.
         * @param fieldNames	Filed names of submitted form
         * @param termNames		Form label names
         * @param values		Direct values from form
         */
        public ErrorLine(String template, List<String> fieldNames, List<String> termNames, List<String> values) {
            this.template = template;
            this.fieldNames.addAll(fieldNames);
            this.termNames.addAll(termNames);
            this.values.addAll(values);
        }

        public String getTemplate() {
            return this.template;
        }

        public List<String> getFieldNames() {
            return this.fieldNames;
        }

        public List<String> getTermNames() {
            return this.termNames;
        }

        public List<String> getValues() {
            return this.values;
        }
    }
}
{'fraction_non_alphanumeric': 0.1010566762728146, 'fraction_numerical': 0.0, 'mean_word_length': 2.989272030651341, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 42, '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': '419487', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1305, 'n_words': 349}