javax.validation.valueextraction.ExtractedValue Maven / Gradle / Ivy
/*
* Bean Validation API
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or .
*/
package javax.validation.valueextraction;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.OptionalInt;
/**
* Marks the type parameter of a generic container type to which a {@link ValueExtractor} is tied
* or specifies the type of the wrapped element(s) of non-generic container types.
*
* Must be given exactly once for a value extractor type.
*
* @author Gunnar Morling
* @author Guillaume Smet
*
* @see ValueExtractor
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@Documented
public @interface ExtractedValue {
/**
* Returns the type of the value extracted by the {@link ValueExtractor}. If not set, returns
* {@code void.class}, meaning the type will be automatically inferred from the type argument
* of the parameterized type.
*
* Used to define value extractors for non-generic wrapper types e.g. {@link OptionalInt}.
*
* May not be used when {@code ExtractedValue} is defined on the type parameter of
* a generic wrapper type. A {@code ValueExtractorDefinitionException} will be thrown in
* this case.
*
* @return the type of the value extracted by the value extractor
*/
Class> type() default void.class;
}