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

org.hibernate.validator.internal.util.privilegedactions.GetDeclaredConstructor Maven / Gradle / Ivy

Go to download

JSR 380's RI, Hibernate Validator version ${hibernate-validator.version} and its dependencies repackaged as OSGi bundle

There is a newer version: 5.1.0
Show newest version
/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or .
 */
package org.hibernate.validator.internal.util.privilegedactions;

import java.lang.reflect.Constructor;
import java.security.PrivilegedAction;

/**
 * Returns the declared constructor with the specified parameter types or {@code null} if it does not exist.
 *
 * @author Emmanuel Bernard
 */
public final class GetDeclaredConstructor implements PrivilegedAction> {
	private final Class clazz;
	private final Class[] params;

	public static  GetDeclaredConstructor action(Class clazz, Class... params) {
		return new GetDeclaredConstructor( clazz, params );
	}

	private GetDeclaredConstructor(Class clazz, Class... params) {
		this.clazz = clazz;
		this.params = params;
	}

	@Override
	public Constructor run() {
		try {
			return clazz.getDeclaredConstructor( params );
		}
		catch (NoSuchMethodException e) {
			return null;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy