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

org.datacleaner.configuration.SimpleInjectionPoint Maven / Gradle / Ivy

/**
 * DataCleaner (community edition)
 * Copyright (C) 2014 Free Software Foundation, Inc.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.datacleaner.configuration;

import java.lang.annotation.Annotation;

/**
 * Represents an {@link InjectionPoint} that is not tied to a field, parameter
 * or other member or property.
 *
 * @param 
 */
public class SimpleInjectionPoint implements InjectionPoint {

    private final Class _class;

    /**
     * Constructs a {@link SimpleInjectionPoint} for requesting a specific class
     *
     * @param cls
     */
    public SimpleInjectionPoint(final Class cls) {
        if (cls == null) {
            throw new IllegalArgumentException("Injection class cannot be null");
        }
        _class = cls;
    }

    /**
     * Factory method to produce an {@link InjectionPoint} that describes the
     * specified class.
     *
     * @param cls
     * @return
     */
    public static final  InjectionPoint of(final Class cls) {
        return new SimpleInjectionPoint<>(cls);
    }

    @Override
    public String toString() {
        return "SimpleInjectionPoint[" + _class.getName() + "]";
    }

    @Override
    public  A getAnnotation(final Class annotationClass) {
        return null;
    }

    @Override
    public Object getInstance() {
        return this;
    }

    @Override
    public Class getBaseType() {
        return _class;
    }

    @Override
    public boolean isGenericType() {
        return false;
    }

    @Override
    public int getGenericTypeArgumentCount() {
        return 0;
    }

    @Override
    public Class getGenericTypeArgument(final int i) throws IndexOutOfBoundsException {
        throw new IndexOutOfBoundsException(
                "This injection point has no generic type arguments, requested index no. " + i);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy