1
2
3
4
5 package com.lexicalscope.jewel.cli.validation;
6
7 import com.lexicalscope.fluent.functions.BiConverter;
8 import com.lexicalscope.jewel.cli.specification.OptionsSpecification;
9 import com.lexicalscope.jewel.cli.specification.ParsedOptionSpecification;
10
11 public class ConverterRawOptionToParsedOptionSpecification implements BiConverter<ParsedOptionSpecification, RawOption>
12 {
13 private final OptionsSpecification<?> specification;
14
15 public ConverterRawOptionToParsedOptionSpecification(final OptionsSpecification<?> specification)
16 {
17 this.specification = specification;
18 }
19
20 @Override
21 public RawOption forward(@SuppressWarnings("unused") final ParsedOptionSpecification from)
22 {
23 throw new IllegalStateException("there is not unique conversion from an option to a string");
24 }
25
26 @Override
27 public ParsedOptionSpecification reverse(final RawOption from)
28 {
29 return specification.getSpecification(from.stringValue());
30 }
31 }