org.hibernate.validator.internal.engine.DefaultParameterNameProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-validator Show documentation
Show all versions of hibernate-validator Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries. These will be removed as time goes by
/*
* 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.engine;
import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import jakarta.validation.ParameterNameProvider;
/**
* A default {@link ParameterNameProvider} implementation which returns parameter names obtained from the Java
* reflection API as mandated by the BV specification.
*
* @author Hardy Ferentschik
* @author Gunnar Morling
*/
public class DefaultParameterNameProvider implements ParameterNameProvider {
@Override
public List getParameterNames(Constructor> constructor) {
return doGetParameterNames( constructor );
}
@Override
public List getParameterNames(Method method) {
return doGetParameterNames( method );
}
private List doGetParameterNames(Executable executable) {
Parameter[] parameters = executable.getParameters();
List parameterNames = new ArrayList<>( parameters.length );
for ( Parameter parameter : parameters ) {
parameterNames.add( parameter.getName() );
}
return Collections.unmodifiableList( parameterNames );
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy