<commit_before>package org.search.nibrs.validation.groupb;

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

import org.search.nibrs.model.GroupBArrestReport;
import org.search.nibrs.model.codes.NIBRSErrorCode;
import org.search.nibrs.validation.rules.NotBlankRule;
import org.search.nibrs.validation.rules.Rule;

/**
 * Factory class that provides Rule implementations to validate the elements contained on the Group B report administrative segment.
 */
public class GroupBArrestReportRulesFactory {

	private List<Rule<GroupBArrestReport>> rulesList;

	public GroupBArrestReportRulesFactory() {
	
		rulesList = new ArrayList<Rule<GroupBArrestReport>>();
	}
	
	/**
	 * Get the list of rules for the GroupB Arrest Report segment factory.
	 * 
	 * @return the list of rules
	 */
	public List<Rule<GroupBArrestReport>> getRulesList() {
		rulesList.add(getRule101("ori", "1"));
		rulesList.add(getRule101("yearOfTape", "Year of Tape"));
		rulesList.add(getRule101("monthOfTape", "Month of Tape"));
		return rulesList;
	}
	
	Rule<GroupBArrestReport> getRule101(String propertyName, String dataElementIdentifier) {
		return new NotBlankRule<GroupBArrestReport>(propertyName, dataElementIdentifier, GroupBArrestReport.class, NIBRSErrorCode._701);
	}
	
}<commit_msg>Implemented rule 704 (month and year of tape)<commit_after>package org.search.nibrs.validation.groupb;

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

import org.search.nibrs.common.NIBRSError;
import org.search.nibrs.model.GroupBArrestReport;
import org.search.nibrs.model.codes.NIBRSErrorCode;
import org.search.nibrs.validation.rules.NotBlankRule;
import org.search.nibrs.validation.rules.NumericValueRule;
import org.search.nibrs.validation.rules.Rule;

/**
 * Factory class that provides Rule implementations to validate the elements contained on the Group B report administrative segment.
 */
public class GroupBArrestReportRulesFactory {

	private List<Rule<GroupBArrestReport>> rulesList;

	public GroupBArrestReportRulesFactory() {
	
		rulesList = new ArrayList<Rule<GroupBArrestReport>>();
	}
	
	/**
	 * Get the list of rules for the GroupB Arrest Report segment factory.
	 * 
	 * @return the list of rules
	 */
	public List<Rule<GroupBArrestReport>> getRulesList() {
		rulesList.add(getRule101("ori", "1"));
		rulesList.add(getRule101("yearOfTape", "Year of Tape"));
		rulesList.add(getRule101("monthOfTape", "Month of Tape"));
		rulesList.add(getRule104("yearOfTape"));
		rulesList.add(getRule104("monthOfTape"));
		return rulesList;
	}
	
	Rule<GroupBArrestReport> getRule101(String propertyName, String dataElementIdentifier) {
		return new NotBlankRule<GroupBArrestReport>(propertyName, dataElementIdentifier, GroupBArrestReport.class, NIBRSErrorCode._701);
	}
	
	Rule<GroupBArrestReport> getRule104(String propertyName) {
		Rule<GroupBArrestReport> ret = null;
		if ("yearOfTape".equals(propertyName)) {
			ret = new NumericValueRule<>(
					subject -> {
						return subject.getYearOfTape();
					},
					(value, target) -> {
						NIBRSError e = null;
						if (value != null && 1991 > value.intValue()) {
							e = target.getErrorTemplate();
							e.setNIBRSErrorCode(NIBRSErrorCode._104);
							e.setDataElementIdentifier("Year of Tape");
							e.setValue(value);
						}
						return e;
					});
		} else if ("monthOfTape".equals(propertyName)) {
			ret = new NumericValueRule<>(
					subject -> {
						return subject.getMonthOfTape();
					},
					(value, target) -> {
						NIBRSError e = null;
						if (value != null && (1 > value.intValue() || 12 < value.intValue())) {
							e = target.getErrorTemplate();
							e.setNIBRSErrorCode(NIBRSErrorCode._104);
							e.setDataElementIdentifier("Month of Tape");
							e.setValue(value);
						}
						return e;
					});
		}
		return ret;
	}
	
}
{'fraction_non_alphanumeric': 0.11718131433095803, 'fraction_numerical': 0.015043547110055424, 'mean_word_length': 4.445402298850575, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 29, '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': '3442586', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1200, 'n_words': 250}