@@ -129,79 +129,28 @@ static ArgumentSet argumentSet(String name, @Nullable Object... arguments) {
129
129
return new ArgumentSet (name , arguments );
130
130
}
131
131
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
-
179
132
/**
180
133
* Factory method for creating an instance of {@code Arguments} based on
181
134
* the supplied {@code arguments} as a {@link List}.
182
135
*
183
136
* @param arguments the arguments as a List to be used for an invocation
184
137
* of the test method; must not be {@code null} but may contain {@code null}
185
138
* @return an instance of {@code Arguments}; never {@code null}
139
+ * @since 6.0
186
140
* @see #arguments(List)
187
141
*/
188
142
@ 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
+
198
147
}
199
148
200
149
/**
201
150
* Factory method for creating an instance of {@code Arguments} based on
202
151
* the supplied {@code arguments} as a {@link List}.
203
152
*
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
205
154
* intended to be used when statically imported — for example, via:
206
155
* {@code import static org.junit.jupiter.params.provider.Arguments.arguments;}
207
156
*
@@ -212,29 +161,37 @@ static Arguments of(@Nullable List<@Nullable Object> arguments) {
212
161
* @see #argumentSet(String, Object...)
213
162
*/
214
163
@ 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 );
217
166
}
218
167
219
168
/**
220
169
* 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.
222
174
*
223
175
* @param name the name of the argument set; must not be {@code null} or blank
224
176
* @param arguments the arguments list to be used for an invocation of the test
225
177
* method; must not be {@code null} but may contain {@code null}
226
178
* @return an {@code ArgumentSet}; never {@code null}
227
179
* @since 6.0
180
+ * @see #argumentSet(String, Object...)
228
181
*/
229
182
@ 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 ) {
231
184
Preconditions .notBlank (name , "name must not be null or blank" );
232
185
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 ());
234
187
}
235
188
236
189
/**
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.
238
195
*
239
196
* @return a mutable List of arguments; never {@code null} but may contain {@code null}
240
197
* @since 6.0
@@ -244,4 +201,50 @@ static ArgumentSet argumentSet(String name, List<@Nullable Object> arguments) {
244
201
return new ArrayList <>(Arrays .asList (get ()));
245
202
}
246
203
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
+ }
247
250
}
0 commit comments