@@ -129,79 +129,28 @@ 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}
139+ * @since 6.0
186140 * @see #arguments(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 ());
146+
198147 }
199148
200149 /**
201150 * Factory method for creating an instance of {@code Arguments} based on
202151 * the supplied {@code arguments} as a {@link List}.
203152 *
204- * <p>This method is an <em>alias</em> for {@link Arguments#of } and is
153+ * <p>This method is an <em>alias</em> for {@link Arguments#from } and is
205154 * intended to be used when statically imported — for example, via:
206155 * {@code import static org.junit.jupiter.params.provider.Arguments.arguments;}
207156 *
@@ -212,29 +161,37 @@ static Arguments of(@Nullable List<@Nullable Object> arguments) {
212161 * @see #argumentSet(String, Object...)
213162 */
214163 @ API (status = EXPERIMENTAL , since = "6.0" )
215- static Arguments arguments (List <@ Nullable Object > arguments ) {
216- return of (arguments );
164+ static Arguments argumentsFrom (List <@ Nullable Object > arguments ) {
165+ return from (arguments );
217166 }
218167
219168 /**
220169 * Factory method for creating an {@link ArgumentSet} based on the supplied
221- * {@code name} and {@code arguments} as a List.
170+ * {@code name} and {@code arguments} as a {@link List}.
171+ *
172+ * <p>This method is a convenient alternative to {@link #argumentSet(String, Object...)}
173+ * when working with {@link List} based inputs.
222174 *
223175 * @param name the name of the argument set; must not be {@code null} or blank
224176 * @param arguments the arguments list to be used for an invocation of the test
225177 * method; must not be {@code null} but may contain {@code null}
226178 * @return an {@code ArgumentSet}; never {@code null}
227179 * @since 6.0
180+ * @see #argumentSet(String, Object...)
228181 */
229182 @ API (status = EXPERIMENTAL , since = "6.0" )
230- static ArgumentSet argumentSet (String name , List <@ Nullable Object > arguments ) {
183+ static ArgumentSet argumentSetFrom (String name , List <@ Nullable Object > arguments ) {
231184 Preconditions .notBlank (name , "name must not be null or blank" );
232185 Preconditions .notNull (arguments , "arguments list must not be null" );
233- return new ArgumentSet (name , arguments .toArray (new Object [ 0 ] ));
186+ return new ArgumentSet (name , arguments .toArray ());
234187 }
235188
236189 /**
237- * Convert the arguments to a mutable List.
190+ * Convert the arguments to a new mutable {@link List} containing the same
191+ * elements as {@link #get()}.
192+ *
193+ * <p>This is useful for test logic that benefits from {@code List} operations such as filtering,
194+ * transformation, or assertions.
238195 *
239196 * @return a mutable List of arguments; never {@code null} but may contain {@code null}
240197 * @since 6.0
@@ -244,4 +201,50 @@ static ArgumentSet argumentSet(String name, List<@Nullable Object> arguments) {
244201 return new ArrayList <>(Arrays .asList (get ()));
245202 }
246203
204+ /**
205+ * Specialization of {@link Arguments} that associates a {@link #getName() name}
206+ * with a set of {@link #get() arguments}.
207+ *
208+ * @since 5.11
209+ * @see Arguments#argumentSet(String, Object...)
210+ * @see org.junit.jupiter.params.ParameterizedTest#ARGUMENT_SET_NAME_PLACEHOLDER
211+ * @see org.junit.jupiter.params.ParameterizedTest#ARGUMENT_SET_NAME_OR_ARGUMENTS_WITH_NAMES_PLACEHOLDER
212+ */
213+ @ API (status = EXPERIMENTAL , since = "5.11" )
214+ final class ArgumentSet implements Arguments {
215+
216+ private final String name ;
217+
218+ private final @ Nullable Object [] arguments ;
219+
220+ private ArgumentSet (String name , @ Nullable Object [] arguments ) {
221+ Preconditions .notBlank (name , "name must not be null or blank" );
222+ Preconditions .notNull (arguments , "arguments array must not be null" );
223+ this .name = name ;
224+ this .arguments = arguments ;
225+ }
226+
227+ /**
228+ * Get the name of this {@code ArgumentSet}.
229+ * @return the name of this {@code ArgumentSet}; never {@code null} or blank
230+ */
231+ public String getName () {
232+ return this .name ;
233+ }
234+
235+ @ Override
236+ public @ Nullable Object [] get () {
237+ return this .arguments ;
238+ }
239+
240+ /**
241+ * Return the {@link #getName() name} of this {@code ArgumentSet}.
242+ * @return the name of this {@code ArgumentSet}
243+ */
244+ @ Override
245+ public String toString () {
246+ return getName ();
247+ }
248+
249+ }
247250}
0 commit comments