<commit_before>package com.googlecode.totallylazy;

import java.lang.reflect.Field;

public class Fields {
    public static Mapper<Field, String> name = new Mapper<Field, String>() {
        @Override
        public String call(Field field) throws Exception {
            return field.getName();
        }
    };

    public static Mapper<Field, Class<?>> type = new Mapper<Field, Class<?>>() {
        @Override
        public Class<?> call(Field field) throws Exception {
            return field.getType();
        }
    };

    public static Mapper<Field, Object> value(final Object instance) {
        return new Mapper<Field, Object>() {
            @Override
            public Object call(Field field) throws Exception {
                return access(field).get(instance);
            }
        };
    }

    public static Mapper<Field, Integer> modifiers = new Mapper<Field, Integer>() {
        @Override
        public Integer call(Field field) throws Exception {
            return field.getModifiers();
        }
    };

    public static Field access(Field field) {
        field.setAccessible(true);
        return field;
    }
}<commit_msg>Added overload with type safe cast<commit_after>package com.googlecode.totallylazy;

import java.lang.reflect.Field;

import static com.googlecode.totallylazy.Unchecked.cast;

public class Fields {
    public static Mapper<Field, String> name = new Mapper<Field, String>() {
        @Override
        public String call(Field field) throws Exception {
            return field.getName();
        }
    };

    public static Mapper<Field, Class<?>> type = new Mapper<Field, Class<?>>() {
        @Override
        public Class<?> call(Field field) throws Exception {
            return field.getType();
        }
    };

    public static <T> Mapper<Field, T> value(final Object instance) {
        return new Mapper<Field, T>() {
            @Override
            public T call(Field field) throws Exception {
                return get(field, instance);
            }
        };
    }

    public static <T> Mapper<Field, T> value(final Object instance, final Class<T> aClass) {
        return new Mapper<Field, T>() {
            @Override
            public T call(Field field) throws Exception {
                return get(field, instance, aClass);
            }
        };
    }

    public static <T> T get(Field field, Object instance) throws IllegalAccessException {
        return cast(access(field).get(instance));
    }

    public static <T> T get(Field field, Object instance, Class<T> aClass) throws IllegalAccessException {
        return aClass.cast(access(field).get(instance));
    }

    public static Mapper<Field, Integer> modifiers = new Mapper<Field, Integer>() {
        @Override
        public Integer call(Field field) throws Exception {
            return field.getModifiers();
        }
    };

    public static Field access(Field field) {
        field.setAccessible(true);
        return field;
    }
}
{'fraction_non_alphanumeric': 0.10264125710464728, 'fraction_numerical': 0.0, 'mean_word_length': 2.298787210584344, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '3942887', 'n_tokens_mistral': 791, 'n_tokens_neox': 776, 'n_words': 234}