Top Description Inners Methods
org.junit.jupiter.params.provider

public @Interface EnumSource

extends Annotation
Annotations
@Target:ANNOTATION_TYPE, METHOD, TYPE
@Retention:RUNTIME
@Documented
@Inherited
@Repeatable:EnumSources
@API
status:STABLE
since:5.7
@ArgumentsSource:EnumArgumentsProvider
@SuppressWarnings:exports
Static Imports
java.util.stream.Collectors.toSet, org.apiguardian.api.API.Status.MAINTAINED, .API.Status.STABLE

@EnumSource is a repeatable ArgumentsSource for constants of an Enum.

The enum constants will be provided as arguments to the annotated @ParameterizedClass or @ParameterizedTest.

The enum type can be specified explicitly using the value attribute. Otherwise, the declared type of the first parameter of the @ParameterizedClass or @ParameterizedTest is used.

The set of enum constants can be restricted via the names, from, to and mode attributes.

Inheritance

This annotation is inherited to subclasses.

Since
5.0
See Also
org.junit.jupiter.params.provider.ArgumentsSource, org.junit.jupiter.params.ParameterizedClass, org.junit.jupiter.params.ParameterizedTest

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
EnumSource.Mode

Enumeration of modes for selecting enum constants by name.

Method Summary

Modifier and TypeMethod and Description
public String
from()

The starting enum constant of the range to be included.

public EnumSource.Mode
mode()

The enum constant selection mode.

public String[]
names()

The names of enum constants to provide, or regular expressions to select the names of enum constants to provide.

public String
to()

The ending enum constant of the range to be included.

public Class<? extends Enum<?>>
value()

The enum type that serves as the source of the enum constants.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

fromback to summary
public String from()

The starting enum constant of the range to be included.

Defaults to an empty string, where the range starts from the first enum constant of the specified enum type.

Annotations
@API
status:MAINTAINED
since:5.13.3
Since
5.12
See Also
value, names, to, mode
modeback to summary
public EnumSource.Mode mode()

The enum constant selection mode.

The mode only applies to the names attribute and does not change the behavior of from and to, which always define a range based on the natural order of the enum constants.

Defaults to INCLUDE.

See Also
Mode#INCLUDE, Mode#EXCLUDE, Mode#MATCH_ALL, Mode#MATCH_ANY, Mode#MATCH_NONE, names, from, to
namesback to summary
public String[] names()

The names of enum constants to provide, or regular expressions to select the names of enum constants to provide.

If no names or regular expressions are specified, and neither from nor to are specified, all enum constants declared in the specified enum type will be provided.

If from or to are specified, the elements in names must fall within the range defined by from and to.

The mode determines how the names are interpreted.

See Also
value, from, to, mode
toback to summary
public String to()

The ending enum constant of the range to be included.

Defaults to an empty string, where the range ends at the last enum constant of the specified enum type.

Annotations
@API
status:MAINTAINED
since:5.13.3
Since
5.12
See Also
value, names, from, mode
valueback to summary
public Class<? extends Enum<?>> value()

The enum type that serves as the source of the enum constants.

If this attribute is not set explicitly, the declared type of the first parameter of the @ParameterizedTest method is used.

See Also
names, from, to, mode
org.junit.jupiter.params.provider back to summary

public final Enum EnumSource.Mode

extends Enum<EnumSource.Mode>
Class Inheritance

Enumeration of modes for selecting enum constants by name.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface

Field Summary

Modifier and TypeField and Description
public static final EnumSource.Mode
EXCLUDE

Select all declared enum constants except those supplied via the EnumSource#names attribute.

public static final EnumSource.Mode
INCLUDE

Select only those enum constants whose names are supplied via the EnumSource#names attribute.

public static final EnumSource.Mode
MATCH_ALL

Select only those enum constants whose names match all patterns supplied via the EnumSource#names attribute.

public static final EnumSource.Mode
MATCH_ANY

Select only those enum constants whose names match any pattern supplied via the EnumSource#names attribute.

public static final EnumSource.Mode
MATCH_NONE

Select only those enum constants whose names match none of the patterns supplied via the EnumSource#names attribute.

private final BiPredicate<String, Set<String>>
private final EnumSource.Mode.Validator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
select(Enum<?> constant, Set<String> names)

pack-priv void
validate(EnumSource enumSource, Set<? extends Enum<?>> constants, Set<String> names)

private static void
validateNames(EnumSource enumSource, Set<? extends Enum<?>> constants, Set<String> names)

private static void
validatePatterns(EnumSource enumSource, Set<? extends Enum<?>> constants, Set<String> names)

public static EnumSource.Mode
public static EnumSource.Mode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

EXCLUDEback to summary
public static final EnumSource.Mode EXCLUDE

Select all declared enum constants except those supplied via the EnumSource#names attribute.

INCLUDEback to summary
public static final EnumSource.Mode INCLUDE

Select only those enum constants whose names are supplied via the EnumSource#names attribute.

MATCH_ALLback to summary
public static final EnumSource.Mode MATCH_ALL

Select only those enum constants whose names match all patterns supplied via the EnumSource#names attribute.

See Also
java.util.stream.Stream#allMatch(java.util.function.Predicate)
MATCH_ANYback to summary
public static final EnumSource.Mode MATCH_ANY

Select only those enum constants whose names match any pattern supplied via the EnumSource#names attribute.

See Also
java.util.stream.Stream#anyMatch(java.util.function.Predicate)
MATCH_NONEback to summary
public static final EnumSource.Mode MATCH_NONE

Select only those enum constants whose names match none of the patterns supplied via the EnumSource#names attribute.

Annotations
@API
status:MAINTAINED
since:5.13.3
Since
5.9
See Also
java.util.stream.Stream#noneMatch(java.util.function.Predicate)
selectorback to summary
private final BiPredicate<String, Set<String>> selector
validatorback to summary
private final EnumSource.Mode.Validator validator

Constructor Detail

Modeback to summary
private Mode(EnumSource.Mode.Validator validator, BiPredicate<String, Set<String>> selector)

Method Detail

selectback to summary
pack-priv boolean select(Enum<?> constant, Set<String> names)
validateback to summary
pack-priv void validate(EnumSource enumSource, Set<? extends Enum<?>> constants, Set<String> names)
validateNamesback to summary
private static void validateNames(EnumSource enumSource, Set<? extends Enum<?>> constants, Set<String> names)
validatePatternsback to summary
private static void validatePatterns(EnumSource enumSource, Set<? extends Enum<?>> constants, Set<String> names)
valueOfback to summary
public static EnumSource.Mode valueOf(String name)
valuesback to summary
public static EnumSource.Mode[] values()
org.junit.jupiter.params.provider back to summary

private Interface EnumSource.Mode.Validator


Method Summary

Modifier and TypeMethod and Description
public void
validate(EnumSource enumSource, Set<? extends Enum<?>> constants, Set<String> names)

Method Detail

validateback to summary
public void validate(EnumSource enumSource, Set<? extends Enum<?>> constants, Set<String> names)