@@ -255,71 +255,82 @@ private static class Init<T> {
255255 *
256256 * @param <T> The type of the option argument value.
257257 */
258+ @ SuppressWarnings ("unchecked" )
258259 @ FunctionalInterface
259260 public interface NamedParam <T > {
260261 /**
261262 * Sets a field value of {@link Init} object that has same fields with
262263 * {@link OptCfg} object and is used to initialized it.
263264 *
264- * @param init {@link Init} object to initialize {@link OptCfg} object.
265+ * @param init An object to initialize {@link OptCfg} object.
265266 */
266- void setTo (Init < T > init );
267+ void setTo (Object init );
267268
268269 /**
269270 * Is the static method to set the {@code storeKey} field like a named
270271 * parameter.
271272 *
273+ * @param <T> The type of the option argument value.
274+ *
272275 * @param storeKey The value of the {@code storeKey} field.
273276 * @return The {@link NamedParam} object for {@code storeKey} field.
274277 */
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 ;
277280 }
278281
279282 /**
280283 * Is the static method to set the {@code names} field like a named
281284 * parameter.
282285 *
286+ * @param <T> The type of the option argument value.
287+ *
283288 * @param names The string array of the {@code names} field.
284289 * @return The {@link NamedParam} object for {@code storeKey} field.
285290 */
286291 @ 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 );
289294 }
290295
291296 /**
292297 * Is the static method to set the {@code names} field like a named
293298 * parameter.
294299 *
300+ * @param <T> The type of the option argument value.
301+ *
295302 * @param list The string list of the {@code names} field.
296303 * @return The {@link NamedParam} object for {@code storeKey} field.
297304 */
298305 @ 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 ;
301308 }
302309
303310 /**
304311 * Is the static method to set the {@code hasArg} field like a named
305312 * parameter.
306313 *
314+ * @param <T> The type of the option argument value.
315+ *
307316 * @param hasArg The value of the {@code hasArg} field.
308317 * @return The {@link NamedParam} object for {@code hasArg} field.
309318 */
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 ;
312321 }
313322
314323 /**
315324 * Is the static method to set the {@code isArray} field like a named
316325 * parameter.
317326 *
327+ * @param <T> The type of the option argument value.
328+ *
318329 * @param isArray The value of the {@code isArray} field.
319330 * @return The {@link NamedParam} object for {@code isArray} field.
320331 */
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 ;
323334 }
324335
325336 /**
@@ -332,7 +343,7 @@ static NamedParam isArray(boolean isArray) {
332343 * @return The {@link NamedParam} object for {@code type} field.
333344 */
334345 static <T > NamedParam <T > type (Class <T > type ) {
335- return init -> init .type = type ;
346+ return init -> (( Init < T >) init ) .type = type ;
336347 }
337348
338349 /**
@@ -345,8 +356,9 @@ static <T> NamedParam<T> type(Class<T> type) {
345356 * @return The {@link NamedParam} object for {@code defaults} field.
346357 */
347358 @ SafeVarargs
359+ @ SuppressWarnings ("varargs" )
348360 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 );
350362 }
351363
352364 /**
@@ -359,29 +371,33 @@ static <T> NamedParam<T> defaults(T ...defaults) {
359371 * @return The {@link NamedParam} object for {@code defaults} field.
360372 */
361373 static <T > NamedParam <T > defaults (List <T > defaults ) {
362- return init -> init .defaults = defaults ;
374+ return init -> (( Init < T >) init ) .defaults = defaults ;
363375 }
364376
365377 /**
366378 * Is the static method to set the {@code desc} field like a named
367379 * parameter.
368380 *
381+ * @param <T> The type of the option argument value.
382+ *
369383 * @param desc The value of the {@code desc} field.
370384 * @return The {@link NamedParam} object for {@code defaults} field.
371385 */
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 ;
374388 }
375389
376390 /**
377391 * Is the static method to set the {@code argInHelp} field like a named
378392 * parameter.
379393 *
394+ * @param <T> The type of the option argument value.
395+ *
380396 * @param argInHelp The value of the {@code argInHelp} field.
381397 * @return The {@link NamedParam} object for {@code argInHelp} field.
382398 */
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 ;
385401 }
386402
387403 /**
@@ -394,7 +410,7 @@ static NamedParam argInHelp(String argInHelp) {
394410 * @return The {@link NamedParam} object for {@code converter} field.
395411 */
396412 static <T > NamedParam <T > converter (Converter <T > converter ) {
397- return init -> init .converter = converter ;
413+ return init -> (( Init < T >) init ) .converter = converter ;
398414 }
399415 }
400416}
0 commit comments