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

net.jqwik.engine.support.MethodParameter Maven / Gradle / Ivy

The newest version!
package net.jqwik.engine.support;

import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;

import org.junit.platform.commons.support.*;

public class MethodParameter {

	public Parameter getRawParameter() {
		return rawParameter;
	}

	private final Parameter rawParameter;
	private final TypeResolution resolution;
	private final int index;

	public MethodParameter(Parameter rawParameter, TypeResolution resolution, int index) {
		this.rawParameter = rawParameter;
		this.resolution = resolution;
		this.index = index;
	}

	public boolean isParameterized() {
		return (resolution.annotatedType() instanceof AnnotatedParameterizedType);
	}

	public boolean isAnnotated(Class annotationType) {
		return AnnotationSupport.isAnnotated(rawParameter, annotationType);
	}

	public  T getAnnotation(Class annotationClass) {
		return findAnnotation(annotationClass).orElse(null);
	}

	public  Optional findAnnotation(Class annotationClass) {
		return AnnotationSupport.findAnnotation(rawParameter, annotationClass);
	}

	public Type getType() {
		return resolution.type();
	}

	@Override
	public String toString() {
		return rawParameter.toString();
	}

	public List findAllAnnotations() {
		return JqwikAnnotationSupport.findAllAnnotations(rawParameter);
	}

	public AnnotatedType getAnnotatedType() {
		return resolution.annotatedType();
	}

	public int getIndex() {
		return index;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy