@@ -255,71 +255,82 @@ private static class Init<T> {
255
255
*
256
256
* @param <T> The type of the option argument value.
257
257
*/
258
+ @ SuppressWarnings ("unchecked" )
258
259
@ FunctionalInterface
259
260
public interface NamedParam <T > {
260
261
/**
261
262
* Sets a field value of {@link Init} object that has same fields with
262
263
* {@link OptCfg} object and is used to initialized it.
263
264
*
264
- * @param init {@link Init} object to initialize {@link OptCfg} object.
265
+ * @param init An object to initialize {@link OptCfg} object.
265
266
*/
266
- void setTo (Init < T > init );
267
+ void setTo (Object init );
267
268
268
269
/**
269
270
* Is the static method to set the {@code storeKey} field like a named
270
271
* parameter.
271
272
*
273
+ * @param <T> The type of the option argument value.
274
+ *
272
275
* @param storeKey The value of the {@code storeKey} field.
273
276
* @return The {@link NamedParam} object for {@code storeKey} field.
274
277
*/
275
- static NamedParam storeKey (String storeKey ) {
276
- return init -> init .storeKey = storeKey ;
278
+ static < T > NamedParam < T > storeKey (String storeKey ) {
279
+ return init -> (( Init < T >) init ) .storeKey = storeKey ;
277
280
}
278
281
279
282
/**
280
283
* Is the static method to set the {@code names} field like a named
281
284
* parameter.
282
285
*
286
+ * @param <T> The type of the option argument value.
287
+ *
283
288
* @param names The string array of the {@code names} field.
284
289
* @return The {@link NamedParam} object for {@code storeKey} field.
285
290
*/
286
291
@ SuppressWarnings ("unchecked" )
287
- static NamedParam names (String ...names ) {
288
- return init -> init .names = List .of (names );
292
+ static < T > NamedParam < T > names (String ...names ) {
293
+ return init -> (( Init < T >) init ) .names = List .of (names );
289
294
}
290
295
291
296
/**
292
297
* Is the static method to set the {@code names} field like a named
293
298
* parameter.
294
299
*
300
+ * @param <T> The type of the option argument value.
301
+ *
295
302
* @param list The string list of the {@code names} field.
296
303
* @return The {@link NamedParam} object for {@code storeKey} field.
297
304
*/
298
305
@ SuppressWarnings ("unchecked" )
299
- static NamedParam names (List <String > list ) {
300
- return init -> init .names = list ;
306
+ static < T > NamedParam < T > names (List <String > list ) {
307
+ return init -> (( Init < T >) init ) .names = list ;
301
308
}
302
309
303
310
/**
304
311
* Is the static method to set the {@code hasArg} field like a named
305
312
* parameter.
306
313
*
314
+ * @param <T> The type of the option argument value.
315
+ *
307
316
* @param hasArg The value of the {@code hasArg} field.
308
317
* @return The {@link NamedParam} object for {@code hasArg} field.
309
318
*/
310
- static NamedParam hasArg (boolean hasArg ) {
311
- return init -> init .hasArg = hasArg ;
319
+ static < T > NamedParam < T > hasArg (boolean hasArg ) {
320
+ return init -> (( Init < T >) init ) .hasArg = hasArg ;
312
321
}
313
322
314
323
/**
315
324
* Is the static method to set the {@code isArray} field like a named
316
325
* parameter.
317
326
*
327
+ * @param <T> The type of the option argument value.
328
+ *
318
329
* @param isArray The value of the {@code isArray} field.
319
330
* @return The {@link NamedParam} object for {@code isArray} field.
320
331
*/
321
- static NamedParam isArray (boolean isArray ) {
322
- return init -> init .isArray = isArray ;
332
+ static < T > NamedParam < T > isArray (boolean isArray ) {
333
+ return init -> (( Init < T >) init ) .isArray = isArray ;
323
334
}
324
335
325
336
/**
@@ -332,7 +343,7 @@ static NamedParam isArray(boolean isArray) {
332
343
* @return The {@link NamedParam} object for {@code type} field.
333
344
*/
334
345
static <T > NamedParam <T > type (Class <T > type ) {
335
- return init -> init .type = type ;
346
+ return init -> (( Init < T >) init ) .type = type ;
336
347
}
337
348
338
349
/**
@@ -345,8 +356,9 @@ static <T> NamedParam<T> type(Class<T> type) {
345
356
* @return The {@link NamedParam} object for {@code defaults} field.
346
357
*/
347
358
@ SafeVarargs
359
+ @ SuppressWarnings ("varargs" )
348
360
static <T > NamedParam <T > defaults (T ...defaults ) {
349
- return init -> init .defaults = List .of (defaults );
361
+ return init -> (( Init < T >) init ) .defaults = List .of (defaults );
350
362
}
351
363
352
364
/**
@@ -359,29 +371,33 @@ static <T> NamedParam<T> defaults(T ...defaults) {
359
371
* @return The {@link NamedParam} object for {@code defaults} field.
360
372
*/
361
373
static <T > NamedParam <T > defaults (List <T > defaults ) {
362
- return init -> init .defaults = defaults ;
374
+ return init -> (( Init < T >) init ) .defaults = defaults ;
363
375
}
364
376
365
377
/**
366
378
* Is the static method to set the {@code desc} field like a named
367
379
* parameter.
368
380
*
381
+ * @param <T> The type of the option argument value.
382
+ *
369
383
* @param desc The value of the {@code desc} field.
370
384
* @return The {@link NamedParam} object for {@code defaults} field.
371
385
*/
372
- static NamedParam desc (String desc ) {
373
- return init -> init .desc = desc ;
386
+ static < T > NamedParam < T > desc (String desc ) {
387
+ return init -> (( Init < T >) init ) .desc = desc ;
374
388
}
375
389
376
390
/**
377
391
* Is the static method to set the {@code argInHelp} field like a named
378
392
* parameter.
379
393
*
394
+ * @param <T> The type of the option argument value.
395
+ *
380
396
* @param argInHelp The value of the {@code argInHelp} field.
381
397
* @return The {@link NamedParam} object for {@code argInHelp} field.
382
398
*/
383
- static NamedParam argInHelp (String argInHelp ) {
384
- return init -> init .argInHelp = argInHelp ;
399
+ static < T > NamedParam < T > argInHelp (String argInHelp ) {
400
+ return init -> (( Init < T >) init ) .argInHelp = argInHelp ;
385
401
}
386
402
387
403
/**
@@ -394,7 +410,7 @@ static NamedParam argInHelp(String argInHelp) {
394
410
* @return The {@link NamedParam} object for {@code converter} field.
395
411
*/
396
412
static <T > NamedParam <T > converter (Converter <T > converter ) {
397
- return init -> init .converter = converter ;
413
+ return init -> (( Init < T >) init ) .converter = converter ;
398
414
}
399
415
}
400
416
}
0 commit comments