<commit_before>/**
 *
 * Copyright 2003-2004 The Apache Software Foundation
 *
 *  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 org.apache.geronimo.gbean;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @version $Revision: 1.20 $ $Date: 2004/06/02 05:33:03 $
 */
public class GBeanInfoFactory {
    private static final Class[] NO_ARGS = {};

    private final String name;

    private final String className;

    private final Map attributes = new HashMap();

    private GConstructorInfo constructor;

    private final Map operations = new HashMap();

    private final Set references = new HashSet();

    private final Set notifications = new HashSet();

    public GBeanInfoFactory(String name) {
        this(name, name, null);
    }

    public GBeanInfoFactory(Class clazz) {
        this(checkNotNull(clazz).getName(), clazz.getName(), null);
    }

    public GBeanInfoFactory(String name, String className) {
        this(name, className, null);
    }

    public GBeanInfoFactory(String name, Class clazz) {
        this(name, checkNotNull(clazz).getName(), null);
    }

    public GBeanInfoFactory(Class clazz, GBeanInfo source) {
        this(checkNotNull(clazz).getName(), clazz.getName(), source);
    }

    public GBeanInfoFactory(String name, Class clazz, GBeanInfo source) {
        this(name, checkNotNull(clazz).getName(), source);
    }

    public GBeanInfoFactory(String name, String className, GBeanInfo source) {
        checkNotNull(name);
        checkNotNull(className);
        this.name = name;
        this.className = className;
        if (source != null) {
            Set sourceAttributes = source.getAttributes();
            if (sourceAttributes != null && !sourceAttributes.isEmpty()) {
                for (Iterator it = sourceAttributes.iterator(); it.hasNext();) {
                    GAttributeInfo attributeInfo = (GAttributeInfo) it.next();
                    attributes.put(attributeInfo.getName(), attributeInfo);
                }
            }
            Set sourceOperations = source.getOperations();
            if (sourceOperations != null && !sourceOperations.isEmpty()) {
                for (Iterator it = sourceOperations.iterator(); it.hasNext();) {
                    GOperationInfo operationInfo = (GOperationInfo) it.next();
                    operations.put(new GOperationSignature(operationInfo.getName(),
                            operationInfo.getParameterList()), operationInfo);
                }
            }
            references.addAll(source.getReferences());
            notifications.addAll(source.getNotifications());
            //in case subclass constructor has same parameters as superclass.
            constructor = source.getConstructor();
        }
    }

    /**
     * Checks whether or not the input argument is null; otherwise it throws
     * {@link IllegalArgumentException}.
     * 
     * @param clazz the input argument to validate
     * @throws IllegalArgumentException if input is null
     */
    private static Class checkNotNull(final Class clazz) {
        if (clazz == null) {
            throw new IllegalArgumentException("null argument supplied");
        }
        return clazz;
    }

    /**
     * Checks whether or not the input argument is null; otherwise it throws
     * {@link IllegalArgumentException}.
     * 
     * @param string the input argument to validate
     * @throws IllegalArgumentException if input is null
     */
    private static String checkNotNull(final String string) {
        if (string == null) {
            throw new IllegalArgumentException("null argument supplied");
        }
        return string;
    }

    public void addInterface(Class intf) {
        addInterface(intf, new String[0]);
    }

    public void addInterface(Class intf, String[] persistentAttributes) {
        Set persistentName = new HashSet(Arrays.asList(persistentAttributes));
        Method[] methods = intf.getMethods();
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];<commit_msg>provide a couple more constructors that work in another classloader<commit_after>/**
 *
 * Copyright 2003-2004 The Apache Software Foundation
 *
 *  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 org.apache.geronimo.gbean;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @version $Revision: 1.21 $ $Date: 2004/07/11 20:56:41 $
 */
public class GBeanInfoFactory {
    private static final Class[] NO_ARGS = {};

    private final String name;

    private final String className;

    private final Map attributes = new HashMap();

    private GConstructorInfo constructor;

    private final Map operations = new HashMap();

    private final Set references = new HashSet();

    private final Set notifications = new HashSet();

    public GBeanInfoFactory(String name) {
        this(name, name, null);
    }

    public GBeanInfoFactory(Class clazz) {
        this(checkNotNull(clazz).getName(), clazz.getName(), null);
    }

    public GBeanInfoFactory(String name, String className) {
        this(name, className, null);
    }

    public GBeanInfoFactory(String name, Class clazz) {
        this(name, checkNotNull(clazz).getName(), null);
    }

    public GBeanInfoFactory(Class clazz, GBeanInfo source) {
        this(checkNotNull(clazz).getName(), clazz.getName(), source);
    }

    public GBeanInfoFactory(String name, GBeanInfo source) {
        this(checkNotNull(name), name, source);
    }

    public GBeanInfoFactory(String name, ClassLoader cl) {
        this(checkNotNull(name), name, GBeanInfo.getGBeanInfo(name, cl));
    }

    public GBeanInfoFactory(String name, Class clazz, GBeanInfo source) {
        this(name, checkNotNull(clazz).getName(), source);
    }

    public GBeanInfoFactory(String name, String className, GBeanInfo source) {
        checkNotNull(name);
        checkNotNull(className);
        this.name = name;
        this.className = className;
        if (source != null) {
            Set sourceAttributes = source.getAttributes();
            if (sourceAttributes != null && !sourceAttributes.isEmpty()) {
                for (Iterator it = sourceAttributes.iterator(); it.hasNext();) {
                    GAttributeInfo attributeInfo = (GAttributeInfo) it.next();
                    attributes.put(attributeInfo.getName(), attributeInfo);
                }
            }
            Set sourceOperations = source.getOperations();
            if (sourceOperations != null && !sourceOperations.isEmpty()) {
                for (Iterator it = sourceOperations.iterator(); it.hasNext();) {
                    GOperationInfo operationInfo = (GOperationInfo) it.next();
                    operations.put(new GOperationSignature(operationInfo.getName(),
                            operationInfo.getParameterList()), operationInfo);
                }
            }
            references.addAll(source.getReferences());
            notifications.addAll(source.getNotifications());
            //in case subclass constructor has same parameters as superclass.
            constructor = source.getConstructor();
        }
    }

    /**
     * Checks whether or not the input argument is null; otherwise it throws
     * {@link IllegalArgumentException}.
     *
     * @param clazz the input argument to validate
     * @throws IllegalArgumentException if input is null
     */
    private static Class checkNotNull(final Class clazz) {
        if (clazz == null) {
            throw new IllegalArgumentException("null argument supplied");
        }
        return clazz;
    }

    /**
     * Checks whether or not the input argument is null; otherwise it throws
     * {@link IllegalArgumentException}.
     *
     * @param string the input argument to validate
     * @throws IllegalArgumentException if input is null
     */
    private static String checkNotNull(final String string) {
        if (string == null) {
            throw new IllegalArgumentException("null argument supplied");
        }
        return string;
    }

    public void addInterface(Class intf) {
        addInterface(intf, new String[0]);
    }

    public void addInterface(Class intf, String[] persistentAttributes) {
        Set persistentName = new HashSet(Arrays.asList(persistentAttributes));
        Method[] methods = intf.getMethods();
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
{'fraction_non_alphanumeric': 0.09624365482233503, 'fraction_numerical': 0.006294416243654823, 'mean_word_length': 2.6950487621905475, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5045461', 'n_tokens_mistral': 2535, 'n_tokens_neox': 2453, 'n_words': 791}