<commit_before>package com.matthewtamlin.spyglass.library.handler_adapters;

import android.content.res.TypedArray;

import com.matthewtamlin.java_utilities.testing.Tested;
import com.matthewtamlin.spyglass.library.handler_annotations.TextArrayHandler;

import static com.matthewtamlin.java_utilities.checkers.NullChecker.checkNotNull;

@Tested(testMethod = "automated")
public class TextArrayHandlerAdapter implements HandlerAdapter<CharSequence[], TextArrayHandler> {
	@Override
	public TypedArrayAccessor<CharSequence[]> getAccessor(final TextArrayHandler annotation) {
		checkNotNull(annotation, "Argument \'annotation\' cannot be null.");

		return new TypedArrayAccessor<CharSequence[]>() {
			@Override
			public boolean valueExistsInArray(final TypedArray array) {
				checkNotNull(array, "Argument \'array\' cannot be null.");

				return array.getTextArray(annotation.attributeId()) != null;
			}

			@Override
			public CharSequence[] getValueFromArray(final TypedArray array) {
				checkNotNull(array, "Argument \'array\' cannot be null.");

				if (valueExistsInArray(array)) {
					return array.getTextArray(annotation.attributeId());
				} else {
					throw new RuntimeException("No attribute found for attribute ID " +
							annotation.attributeId());
				}
			}
		};
	}

	@Override
	public boolean attributeIsMandatory(final TextArrayHandler annotation) {
		checkNotNull(annotation, "Argument \'annotation\' cannot be null.");<commit_msg>Implemented getAttributeId()<commit_after>package com.matthewtamlin.spyglass.library.handler_adapters;

import android.content.res.TypedArray;

import com.matthewtamlin.java_utilities.testing.Tested;
import com.matthewtamlin.spyglass.library.handler_annotations.BooleanHandler;
import com.matthewtamlin.spyglass.library.handler_annotations.TextArrayHandler;

import static com.matthewtamlin.java_utilities.checkers.NullChecker.checkNotNull;

@Tested(testMethod = "automated")
public class TextArrayHandlerAdapter implements HandlerAdapter<CharSequence[], TextArrayHandler> {
	@Override
	public TypedArrayAccessor<CharSequence[]> getAccessor(final TextArrayHandler annotation) {
		checkNotNull(annotation, "Argument \'annotation\' cannot be null.");

		return new TypedArrayAccessor<CharSequence[]>() {
			@Override
			public boolean valueExistsInArray(final TypedArray array) {
				checkNotNull(array, "Argument \'array\' cannot be null.");

				return array.getTextArray(annotation.attributeId()) != null;
			}

			@Override
			public CharSequence[] getValueFromArray(final TypedArray array) {
				checkNotNull(array, "Argument \'array\' cannot be null.");

				if (valueExistsInArray(array)) {
					return array.getTextArray(annotation.attributeId());
				} else {
					throw new RuntimeException("No attribute found for attribute ID " +
							annotation.attributeId());
				}
			}
		};
	}

	@Override
	public int getAttributeId(final TextArrayHandler annotation) {
		checkNotNull(annotation, "Argument \'annotation\' cannot be null.");

		return annotation.attributeId();
	}

	@Override
	public boolean attributeIsMandatory(final TextArrayHandler annotation) {
		checkNotNull(annotation, "Argument \'annotation\' cannot be null.");
{'fraction_non_alphanumeric': 0.10404261986837982, 'fraction_numerical': 0.0, 'mean_word_length': 5.595041322314049, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3878557', 'n_tokens_mistral': 999, 'n_tokens_neox': 866, 'n_words': 199}