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

import android.content.res.TypedArray;


import com.matthewtamlin.spyglass.library.call_handler_annotations.EnumConstantHandler;

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

public class EnumConstantHandlerAdapter implements CallHandlerAdapter<EnumConstantHandler> {

}<commit_msg>Implemented interface<commit_after>package com.matthewtamlin.spyglass.library.call_handler_adapters;

import android.content.res.TypedArray;


import com.matthewtamlin.spyglass.library.call_handler_annotations.EnumConstantHandler;

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

public class EnumConstantHandlerAdapter implements CallHandlerAdapter<EnumConstantHandler> {
	@Override
	public boolean shouldCallMethod(final EnumConstantHandler annotation, final TypedArray attrs) {
		checkNotNull(annotation, "Argument \'annotation\' cannot be null.");
		checkNotNull(attrs, "Argument \'attrs\' cannot be null.");

		if (arrayContainsValue(annotation, attrs)) {
			return attrs.getInt(annotation.attributeId(), 0) == annotation.ordinal();
		} else {
			return false;
		}
	}

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

		return annotation.attributeId();
	}

	private static boolean arrayContainsValue(
			final EnumConstantHandler annotation,
			final TypedArray attrs) {

		// Compare two different results to see if the default is consistently returned
		final int reading1 = attrs.getInt(annotation.attributeId(), 0);
		final int reading2 = attrs.getInt(annotation.attributeId(), 1);

		return !((reading1 == 0) && (reading2 == 1));
	}
}
{'fraction_non_alphanumeric': 0.0931537598204265, 'fraction_numerical': 0.005050505050505051, 'mean_word_length': 6.337448559670782, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7397565', 'n_tokens_mistral': 534, 'n_tokens_neox': 494, 'n_words': 114}