<commit_before>package net.sf.cglib.transform;

import net.sf.cglib.core.*;
import net.sf.cglib.core.Signature;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Type;

public class AccessFieldTransformer extends EmittingTransformer {
    private Callback callback;

    public AccessFieldTransformer(Callback callback) {
        this.callback = callback;
    }

    public interface Callback {
        String getPropertyName(Type owner, String fieldName);
    }

    protected Emitter getEmitter(ClassVisitor cv) {
        return new Emitter(cv) {
            public void declare_field(int access, String name, Type type, Object value) {
                super.declare_field(access, name, type, value);

                String property = callback.getPropertyName(getClassType(), name);
                begin_method(Constants.ACC_PUBLIC,
                             new Signature("get" + property,
                                           type,
                                           Constants.TYPES_EMPTY),
                             null);
                load_this();
                getfield(name);
                return_value();

                begin_method(Constants.ACC_PUBLIC,
                             new Signature("set" + property,
                                           Type.VOID_TYPE,
                                           new Type[]{ type }),
                             null);
                load_this();
                load_arg(0);
                putfield(name);
                return_value();
            }
        };
    }
}<commit_msg>make callback work as filter too<commit_after>package net.sf.cglib.transform;

import net.sf.cglib.core.*;
import net.sf.cglib.core.Signature;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Type;

public class AccessFieldTransformer extends EmittingTransformer {
    private Callback callback;

    public AccessFieldTransformer(Callback callback) {
        this.callback = callback;
    }

    public interface Callback {
        String getPropertyName(Type owner, String fieldName);
    }

    protected Emitter getEmitter(ClassVisitor cv) {
        return new Emitter(cv) {
            public void declare_field(int access, String name, Type type, Object value) {
                super.declare_field(access, name, type, value);

                String property = callback.getPropertyName(getClassType(), name);
                if (property != null) {
                    begin_method(Constants.ACC_PUBLIC,
                                 new Signature("get" + property,
                                               type,
                                               Constants.TYPES_EMPTY),
                                 null);
                    load_this();
                    getfield(name);
                    return_value();

                    begin_method(Constants.ACC_PUBLIC,
                                 new Signature("set" + property,
                                               Type.VOID_TYPE,
                                               new Type[]{ type }),
                                 null);
                    load_this();
                    load_arg(0);
                    putfield(name);
                    return_value();
                }
            }
        };
    }
}
{'fraction_non_alphanumeric': 0.07736131934032983, 'fraction_numerical': 0.0005997001499250374, 'mean_word_length': 1.284931506849315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4738685', 'n_tokens_mistral': 772, 'n_tokens_neox': 734, 'n_words': 166}