<commit_before>/*
 *  Copyright 2011 <NAME>, <EMAIL>
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.ajah.util.reflect;

import java.lang.reflect.Field;
import java.util.Date;

import com.ajah.util.AjahUtils;
import com.ajah.util.FromStringable;
import com.ajah.util.Identifiable;
import com.ajah.util.Named;
import com.ajah.util.ToStringable;

/**
 * Java reflection utilities.
 * 
 * @author <a href="http://efsavage.com"><NAME></a>, <a
 *         href="mailto:<EMAIL>"><EMAIL></a>.
 */
public class IntrospectionUtils {

	/**
	 * Checks to see if the field's type is a boolean.
	 * 
	 * @param field
	 *            The field to check the type of, required.
	 * @return true if the field's type is a long
	 */
	public static boolean isBoolean(final Field field) {
		AjahUtils.requireParam(field, "field");
		return boolean.class.isAssignableFrom(field.getType());
	}

	/**
	 * Checks to see if the field's type is a {@link Date}.
	 * 
	 * @param field
	 *            The field to check the type of, required.
	 * @return true if the field's type is a Date
	 */
	public static boolean isDate(final Field field) {
		AjahUtils.requireParam(field, "field");
		return Date.class.isAssignableFrom(field.getType());
	}

	/**
	 * Checks to see if the field's type is an {@link Enum}. Note: There is an
	 * easier method that does this already, {@link Class#isEnum()}, this method
	 * is just included here for consistency.
	 * 
	 * @param field
	 *            The field to check the type of, required.<commit_msg>Add isBigDecimal()<commit_after>/*
 *  Copyright 2011 <NAME>, <EMAIL>
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.ajah.util.reflect;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.Date;

import com.ajah.util.AjahUtils;
import com.ajah.util.FromStringable;
import com.ajah.util.Identifiable;
import com.ajah.util.Named;
import com.ajah.util.ToStringable;

/**
 * Java reflection utilities.
 * 
 * @author <a href="http://efsavage.com"><NAME></a>, <a
 *         href="mailto:<EMAIL>"><EMAIL></a>.
 */
public class IntrospectionUtils {

	/**
	 * Checks to see if the field's type is a boolean.
	 * 
	 * @param field
	 *            The field to check the type of, required.
	 * @return true if the field's type is a long
	 */
	public static boolean isBoolean(final Field field) {
		AjahUtils.requireParam(field, "field");
		return boolean.class.isAssignableFrom(field.getType());
	}

	/**
	 * Checks to see if the field's type is a {@link Date}.
	 * 
	 * @param field
	 *            The field to check the type of, required.
	 * @return true if the field's type is a Date
	 */
	public static boolean isDate(final Field field) {
		AjahUtils.requireParam(field, "field");
		return Date.class.isAssignableFrom(field.getType());
	}

	/**
	 * Checks to see if the field's type is a {@link BigDecimal}.
	 * 
	 * @param field
	 *            The field to check the type of, required.
	 * @return true if the field's type is a BigDecimal
	 */
	public static boolean isBigDecimal(final Field field) {
		AjahUtils.requireParam(field, "field");
		return BigDecimal.class.isAssignableFrom(field.getType());
	}

	/**
	 * Checks to see if the field's type is an {@link Enum}. Note: There is an
	 * easier method that does this already, {@link Class#isEnum()}, this method
	 * is just included here for consistency.
	 * 
	 * @param field
	 *            The field to check the type of, required.
{'fraction_non_alphanumeric': 0.10876803551609324, 'fraction_numerical': 0.003551609322974473, 'mean_word_length': 3.230985915492958, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6721355', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1300, 'n_words': 502}