@@ -129,81 +129,29 @@ static ArgumentSet argumentSet(String name, @Nullable Object... arguments) {
129129 return new ArgumentSet (name , arguments );
130130 }
131131
132- /**
133- * Specialization of {@link Arguments} that associates a {@link #getName() name}
134- * with a set of {@link #get() arguments}.
135- *
136- * @since 5.11
137- * @see Arguments#argumentSet(String, Object...)
138- * @see org.junit.jupiter.params.ParameterizedTest#ARGUMENT_SET_NAME_PLACEHOLDER
139- * @see org.junit.jupiter.params.ParameterizedTest#ARGUMENT_SET_NAME_OR_ARGUMENTS_WITH_NAMES_PLACEHOLDER
140- */
141- @ API (status = EXPERIMENTAL , since = "5.11" )
142- final class ArgumentSet implements Arguments {
143-
144- private final String name ;
145-
146- private final @ Nullable Object [] arguments ;
147-
148- private ArgumentSet (String name , @ Nullable Object [] arguments ) {
149- Preconditions .notBlank (name , "name must not be null or blank" );
150- Preconditions .notNull (arguments , "arguments array must not be null" );
151- this .name = name ;
152- this .arguments = arguments ;
153- }
154-
155- /**
156- * Get the name of this {@code ArgumentSet}.
157- * @return the name of this {@code ArgumentSet}; never {@code null} or blank
158- */
159- public String getName () {
160- return this .name ;
161- }
162-
163- @ Override
164- public @ Nullable Object [] get () {
165- return this .arguments ;
166- }
167-
168- /**
169- * Return the {@link #getName() name} of this {@code ArgumentSet}.
170- * @return the name of this {@code ArgumentSet}
171- */
172- @ Override
173- public String toString () {
174- return getName ();
175- }
176-
177- }
178-
179132 /**
180133 * Factory method for creating an instance of {@code Arguments} based on
181134 * the supplied {@code arguments} as a {@link List}.
182135 *
183136 * @param arguments the arguments as a List to be used for an invocation
184137 * of the test method; must not be {@code null} but may contain {@code null}
185138 * @return an instance of {@code Arguments}; never {@code null}
186- * @see #arguments(List)
139+ * @since 6.0
140+ * @see #argumentsFrom(List)
187141 */
188142 @ API (status = EXPERIMENTAL , since = "6.0" )
189- static Arguments of (@ Nullable List <@ Nullable Object > arguments ) {
190- if (arguments == null ) {
191- return of ((Object ) null ); // Properly wrap null
192- }
193- if (arguments .isEmpty ()) {
194- // Must still return empty arguments array
195- return of (new Object [0 ]);
196- }
197- return () -> arguments .toArray (new Object [0 ]);
143+ static Arguments from (List <@ Nullable Object > arguments ) {
144+ Preconditions .notNull (arguments , "arguments must not be null" );
145+ return of (arguments .toArray ());
198146 }
199147
200148 /**
201149 * Factory method for creating an instance of {@code Arguments} based on
202150 * the supplied {@code arguments} as a {@link List}.
203151 *
204- * <p>This method is an <em>alias</em> for {@link Arguments#of } and is
152+ * <p>This method is an <em>alias</em> for {@link Arguments#from } and is
205153 * intended to be used when statically imported — for example, via:
206- * {@code import static org.junit.jupiter.params.provider.Arguments.arguments ;}
154+ * {@code import static org.junit.jupiter.params.provider.Arguments.argumentsFrom ;}
207155 *
208156 * @param arguments the arguments as a List to be used for an invocation of the test
209157 * method; must not be {@code null} but may contain {@code null}
@@ -212,29 +160,37 @@ static Arguments of(@Nullable List<@Nullable Object> arguments) {
212160 * @see #argumentSet(String, Object...)
213161 */
214162 @ API (status = EXPERIMENTAL , since = "6.0" )
215- static Arguments arguments (List <@ Nullable Object > arguments ) {
216- return of (arguments );
163+ static Arguments argumentsFrom (List <@ Nullable Object > arguments ) {
164+ return from (arguments );
217165 }
218166
219167 /**
220168 * Factory method for creating an {@link ArgumentSet} based on the supplied
221- * {@code name} and {@code arguments} as a List.
169+ * {@code name} and {@code arguments} as a {@link List}.
170+ *
171+ * <p>This method is a convenient alternative to {@link #argumentSet(String, Object...)}
172+ * when working with {@link List} based inputs.
222173 *
223174 * @param name the name of the argument set; must not be {@code null} or blank
224175 * @param arguments the arguments list to be used for an invocation of the test
225176 * method; must not be {@code null} but may contain {@code null}
226177 * @return an {@code ArgumentSet}; never {@code null}
227178 * @since 6.0
179+ * @see #argumentSet(String, Object...)
228180 */
229181 @ API (status = EXPERIMENTAL , since = "6.0" )
230- static ArgumentSet argumentSet (String name , List <@ Nullable Object > arguments ) {
182+ static ArgumentSet argumentSetFrom (String name , List <@ Nullable Object > arguments ) {
231183 Preconditions .notBlank (name , "name must not be null or blank" );
232184 Preconditions .notNull (arguments , "arguments list must not be null" );
233- return new ArgumentSet (name , arguments .toArray (new Object [ 0 ] ));
185+ return new ArgumentSet (name , arguments .toArray ());
234186 }
235187
236188 /**
237- * Convert the arguments to a mutable List.
189+ * Convert the arguments to a new mutable {@link List} containing the same
190+ * elements as {@link #get()}.
191+ *
192+ * <p>This is useful for test logic that benefits from {@code List} operations such as filtering,
193+ * transformation, or assertions.
238194 *
239195 * @return a mutable List of arguments; never {@code null} but may contain {@code null}
240196 * @since 6.0
@@ -244,4 +200,50 @@ static ArgumentSet argumentSet(String name, List<@Nullable Object> arguments) {
244200 return new ArrayList <>(Arrays .asList (get ()));
245201 }
246202
203+ /**
204+ * Specialization of {@link Arguments} that associates a {@link #getName() name}
205+ * with a set of {@link #get() arguments}.
206+ *
207+ * @since 5.11
208+ * @see Arguments#argumentSet(String, Object...)
209+ * @see org.junit.jupiter.params.ParameterizedTest#ARGUMENT_SET_NAME_PLACEHOLDER
210+ * @see org.junit.jupiter.params.ParameterizedTest#ARGUMENT_SET_NAME_OR_ARGUMENTS_WITH_NAMES_PLACEHOLDER
211+ */
212+ @ API (status = EXPERIMENTAL , since = "5.11" )
213+ final class ArgumentSet implements Arguments {
214+
215+ private final String name ;
216+
217+ private final @ Nullable Object [] arguments ;
218+
219+ private ArgumentSet (String name , @ Nullable Object [] arguments ) {
220+ Preconditions .notBlank (name , "name must not be null or blank" );
221+ Preconditions .notNull (arguments , "arguments array must not be null" );
222+ this .name = name ;
223+ this .arguments = arguments ;
224+ }
225+
226+ /**
227+ * Get the name of this {@code ArgumentSet}.
228+ * @return the name of this {@code ArgumentSet}; never {@code null} or blank
229+ */
230+ public String getName () {
231+ return this .name ;
232+ }
233+
234+ @ Override
235+ public @ Nullable Object [] get () {
236+ return this .arguments ;
237+ }
238+
239+ /**
240+ * Return the {@link #getName() name} of this {@code ArgumentSet}.
241+ * @return the name of this {@code ArgumentSet}
242+ */
243+ @ Override
244+ public String toString () {
245+ return getName ();
246+ }
247+
248+ }
247249}
0 commit comments