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

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

There is a newer version: 8.0.1.Final
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.security.PrivilegedAction;

/**
 * Checks if an external class is present in the provided class loader.
 */
public final class IsClassPresent implements PrivilegedAction {

	private final String className;

	private final ClassLoader classLoader;

	public static IsClassPresent action(String className, ClassLoader classLoader) {
		return new IsClassPresent( className, classLoader );
	}

	private IsClassPresent(String className, ClassLoader classLoader) {
		this.className = className;
		this.classLoader = classLoader;
	}

	@Override
	public Boolean run() {
		try {
			Class.forName( className, false, classLoader );
			return Boolean.TRUE;
		}
		catch (ClassNotFoundException e) {
			return Boolean.FALSE;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy