<commit_before>/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you 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 org.apache.mina.statemachine;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

import org.apache.mina.statemachine.context.SingletonStateContextLookup;
import org.apache.mina.statemachine.context.StateContext;
import org.apache.mina.statemachine.context.StateContextLookup;
import org.apache.mina.statemachine.event.DefaultEventFactory;
import org.apache.mina.statemachine.event.Event;
import org.apache.mina.statemachine.event.EventArgumentsInterceptor;
import org.apache.mina.statemachine.event.EventFactory;
import org.apache.mina.statemachine.event.UnhandledEventException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Used to create proxies which will forward all method calls on them to a
 * {@link StateMachine}.
 *
 * @author The Apache MINA Project (<EMAIL>)
 * @version $Rev$, $Date$
 */
public class StateMachineProxyBuilder {
    private static final Logger log = LoggerFactory
            .getLogger(StateMachineProxyBuilder.class);

    private static final Object[] EMPTY_ARGUMENTS = new Object[0];

    private StateContextLookup contextLookup = new SingletonStateContextLookup();

    private EventFactory eventFactory = new DefaultEventFactory();

    private EventArgumentsInterceptor interceptor = null;

    private boolean ignoreUnhandledEvents = false;

    private boolean ignoreStateContextLookupFailure = false;

    // the classloader to use, if null, then will use the class local one
    private ClassLoader defaultCl = null; 

    public StateMachineProxyBuilder() {
    }

    public StateMachineProxyBuilder setStateContextLookup(
            StateContextLookup contextLookup) {
        this.contextLookup = contextLookup;
        return this;
    }

    public StateMachineProxyBuilder setEventFactory(EventFactory eventFactory) {
        this.eventFactory = eventFactory;
        return this;
    }

    public StateMachineProxyBuilder setEventArgumentsInterceptor(
            EventArgumentsInterceptor interceptor) {
        this.interceptor = interceptor;
        return this;
    }

    public StateMachineProxyBuilder setIgnoreUnhandledEvents(boolean b) {
        this.ignoreUnhandledEvents = b;
        return this;
    }

    public StateMachineProxyBuilder setIgnoreStateContextLookupFailure(boolean b) {
        this.ignoreStateContextLookupFailure = b;
        return this;
    }

    /**
     * Set the class loader to use for instanciate proxies.
     * @params cl the class loader
     */
    public void setClassLoader(ClassLoader cl) {
        this.defaultCl = cl;
    }

    @SuppressWarnings("unchecked")
    public <T> T create(Class<T> iface, StateMachine sm) {
        return (T) create(new Class[] { iface }, sm);
    }
<commit_msg>fixing the SM proxyt builder setClassLoader method for returning "this" for method chaining<commit_after>/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you 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 org.apache.mina.statemachine;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

import org.apache.mina.statemachine.context.SingletonStateContextLookup;
import org.apache.mina.statemachine.context.StateContext;
import org.apache.mina.statemachine.context.StateContextLookup;
import org.apache.mina.statemachine.event.DefaultEventFactory;
import org.apache.mina.statemachine.event.Event;
import org.apache.mina.statemachine.event.EventArgumentsInterceptor;
import org.apache.mina.statemachine.event.EventFactory;
import org.apache.mina.statemachine.event.UnhandledEventException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Used to create proxies which will forward all method calls on them to a
 * {@link StateMachine}.
 *
 * @author The Apache MINA Project (<EMAIL>)
 * @version $Rev$, $Date$
 */
public class StateMachineProxyBuilder {
    private static final Logger log = LoggerFactory
            .getLogger(StateMachineProxyBuilder.class);

    private static final Object[] EMPTY_ARGUMENTS = new Object[0];

    private StateContextLookup contextLookup = new SingletonStateContextLookup();

    private EventFactory eventFactory = new DefaultEventFactory();

    private EventArgumentsInterceptor interceptor = null;

    private boolean ignoreUnhandledEvents = false;

    private boolean ignoreStateContextLookupFailure = false;

    // the classloader to use, if null, then will use the class local one
    private ClassLoader defaultCl = null; 

    public StateMachineProxyBuilder() {
    }

    public StateMachineProxyBuilder setStateContextLookup(
            StateContextLookup contextLookup) {
        this.contextLookup = contextLookup;
        return this;
    }

    public StateMachineProxyBuilder setEventFactory(EventFactory eventFactory) {
        this.eventFactory = eventFactory;
        return this;
    }

    public StateMachineProxyBuilder setEventArgumentsInterceptor(
            EventArgumentsInterceptor interceptor) {
        this.interceptor = interceptor;
        return this;
    }

    public StateMachineProxyBuilder setIgnoreUnhandledEvents(boolean b) {
        this.ignoreUnhandledEvents = b;
        return this;
    }

    public StateMachineProxyBuilder setIgnoreStateContextLookupFailure(boolean b) {
        this.ignoreStateContextLookupFailure = b;
        return this;
    }

    /**
     * Set the class loader to use for instanciate proxies.
     * @params cl the class loader
     * @return StateMachineProxyBuilder this for chaining 
     */
    public StateMachineProxyBuilder setClassLoader(ClassLoader cl) {
        this.defaultCl = cl;
        return this;
    }

    @SuppressWarnings("unchecked")
    public <T> T create(Class<T> iface, StateMachine sm) {
        return (T) create(new Class[] { iface }, sm);
    }

{'fraction_non_alphanumeric': 0.07191041554236373, 'fraction_numerical': 0.0018888289260658392, 'mean_word_length': 3.712650985378258, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6747777', 'n_tokens_mistral': 1946, 'n_tokens_neox': 1914, 'n_words': 619}