All Downloads are FREE. Search and download functionalities are using the official Maven repository.

patterntesting.runtime.util.reflect.ConstructorSignatureImpl Maven / Gradle / Ivy

Go to download

PatternTesting Runtime (patterntesting-rt) is the runtime component for the PatternTesting framework. It provides the annotations and base classes for the PatternTesting testing framework (e.g. patterntesting-check, patterntesting-concurrent or patterntesting-exception) but can be also used standalone for classpath monitoring or profiling. It uses AOP and AspectJ to perform this feat.

There is a newer version: 2.4.0
Show newest version
/*
 * $Id: ConstructorSignatureImpl.java,v 1.4 2011/07/09 21:43:22 oboehm Exp $
 *
 * Copyright (c) 2009 by Oliver Boehm
 *
 * 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 orimplied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * (c)reated 04.04.2009 by oliver ([email protected])
 */
package patterntesting.runtime.util.reflect;

import java.lang.reflect.Constructor;

import org.aspectj.lang.reflect.ConstructorSignature;
import org.slf4j.*;

import patterntesting.runtime.annotation.UnsupportedOperation;
import patterntesting.runtime.util.Converter;

/**
 * The Class ConstructorSignatureImpl.
 *
 * @author oliver
 * @since 04.04.2009
 * @version $Revision: 1.4 $
 */
public class ConstructorSignatureImpl implements ConstructorSignature {

    private static final Logger log = LoggerFactory.getLogger(ConstructorSignatureImpl.class);
    private final Constructor ctor;

    /**
     * Instantiates a new constructor signature impl.
     *
     * @param ctor the ctor
     */
    public ConstructorSignatureImpl(final Constructor ctor) {
        this.ctor = ctor;
    }

    /**
     * @see org.aspectj.lang.reflect.ConstructorSignature#getConstructor()
     */
    public Constructor getConstructor() {
        return this.ctor;
    }

    /**
     * Gets the exception types.
     *
     * @return the exception types
     *
     * @see org.aspectj.lang.reflect.CodeSignature#getExceptionTypes()
     */
    public Class[] getExceptionTypes() {
        return this.ctor.getExceptionTypes();
    }

    /**
     * Gets the parameter names.
     *
     * @return the parameter names
     *
     * @see org.aspectj.lang.reflect.CodeSignature#getParameterNames()
     */
    @UnsupportedOperation
    public String[] getParameterNames() {
        log.debug("this operation is not implemented");
        return null;
    }

    /**
     * Gets the parameter types.
     *
     * @return the parameter types
     *
     * @see org.aspectj.lang.reflect.CodeSignature#getParameterTypes()
     */
    public Class[] getParameterTypes() {
        return this.ctor.getParameterTypes();
    }

    /**
     * Gets the declaring type.
     *
     * @return the declaring type
     *
     * @see org.aspectj.lang.Signature#getDeclaringType()
     */
    public Class getDeclaringType() {
        return this.ctor.getDeclaringClass();
    }

    /**
     * Gets the declaring type name.
     *
     * @return the declaring type name
     *
     * @see org.aspectj.lang.Signature#getDeclaringTypeName()
     */
    public String getDeclaringTypeName() {
        return this.getDeclaringType().getName();
    }

    /**
     * Gets the modifiers.
     *
     * @return the modifiers
     *
     * @see org.aspectj.lang.Signature#getModifiers()
     */
    public int getModifiers() {
        return this.ctor.getModifiers();
    }

    /**
     * Gets the name.
     *
     * @return the name
     *
     * @see org.aspectj.lang.Signature#getName()
     */
    public String getName() {
        return "";
    }

    /**
     * To long string.
     *
     * @return the string
     *
     * @see org.aspectj.lang.Signature#toLongString()
     */
    public String toLongString() {
        return this.ctor.toGenericString();
    }

    /**
     * To short string.
     *
     * @return the string
     *
     * @see org.aspectj.lang.Signature#toShortString()
     */
    public String toShortString() {
        return this.ctor.toString();
    }

    /**
     * To string.
     *
     * @return the string
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return this.getDeclaringTypeName() + "("
                + Converter.toShortString(this.getParameterTypes()) + ")";
    }

}

/**
 * $Log: ConstructorSignatureImpl.java,v $
 * Revision 1.4  2011/07/09 21:43:22  oboehm
 * switched from commons-logging to SLF4J
 *
 * Revision 1.3  2010/04/22 18:32:01  oboehm
 * compiler warnings fixed
 *
 * Revision 1.2  2010/04/22 18:27:19  oboehm
 * code cleanup of src/main/java
 *
 * Revision 1.1  2010/01/05 13:26:17  oboehm
 * begin with 1.0
 *
 * Revision 1.5  2009/12/28 10:07:23  oboehm
 * missing Javadocs completed
 *
 * Revision 1.4  2009/12/19 22:34:09  oboehm
 * trailing spaces removed
 *
 * Revision 1.3  2009/09/25 14:49:43  oboehm
 * javadocs completed with the help of JAutodoc
 *
 * Revision 1.2  2009/04/09 18:30:47  oboehm
 * no longer double entries (bug 2745302 fixed)
 *
 * Revision 1.1  2009/04/06 07:08:53  oboehm
 * detection of never called constructors implemented
 *
 * $Source: /cvsroot/patterntesting/PatternTesting10/patterntesting-rt/src/main/java/patterntesting/runtime/util/reflect/ConstructorSignatureImpl.java,v $
 */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy