java.util.logging.Level is not a simple type, the only way to get complex
types to work is to have the appropriate annotations
<https://github.com/FasterXML/jackson-annotations> on the class.
Unfortunately this is a class that your not the author of, the best bet is
to not use the java type but to substitute it with something that you have
control over.

For example, Dataflow
<https://github.com/apache/incubator-beam/blob/master/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/options/DataflowWorkerLoggingOptions.java>
uses its own enum (which is a simple type) and then internally converts the
representation.
You could also have an enum and even choose to add methods
<http://stackoverflow.com/questions/18883646/java-enum-methods> to it which
can convert between your enum and java.util..logging.Level instances.

If you had an enum with "ERROR", then on the command line you would specify
'--logLevel=ERROR'

Luke


On Fri, Sep 2, 2016 at 7:17 AM, Shen Li <cs.she...@gmail.com> wrote:

> Hi JB,
>
> Thanks a lot for your response. I still don't understand if the type of the
> setter and getter is not simple properties (String, int, long, boolean,
> etc.), how should I compose the JSON argument in the command line. For
> example, my Options interface is like below:
>
> import java.util.logging.Level;
>
> private Interface Options extends PipelineOptions {
>     @Description("log level")
>     Level getLogLevel();
>     void setLogLevel(Level value);
> }
>
>
> If I want the log level to be INFO, what JSON string should I pass to
> "--logLevel=" command line argument?
>
> Thanks,
>
> Shen
>
> On Fri, Sep 2, 2016 at 9:31 AM, Jean-Baptiste Onofré <j...@nanthrax.net>
> wrote:
>
> > Hi Shen,
> >
> > you can extend PipelineOptions like this:
> >
> >     private interface Options extends PipelineOptions {
> >         String GDELT_EVENTS_URL = "http://data.gdeltproject.org/events/
> ";
> >
> >         @Description("GDELT file date")
> >         @Default.InstanceFactory(GDELTFileFactory.class)
> >         String getDate();
> >         void setDate(String value);
> >
> >         @Description("Input Path")
> >         String getInput();
> >         void setInput(String value);
> >
> >         @Description("Output Path")
> >         String getOutput();
> >         void setOutput(String value);
> >
> >         class GDELTFileFactory implements DefaultValueFactory<String> {
> >             public String create(PipelineOptions options) {
> >                 SimpleDateFormat format = new
> SimpleDateFormat("yyyyMMdd");
> >                 return format.format(new Date());
> >             }
> >         }
> >     }
> >
> > and then:
> >
> > Options options = PipelineOptionsFactory.fromArg
> > s(args).withValidation().as(Options.class);
> >
> > Regards
> > JB
> >
> >
> > On 09/02/2016 03:21 PM, Shen Li wrote:
> >
> >> Hi,
> >>
> >> I am trying to understand how can I extend PipelineOptions to add
> getters
> >> and setters with my custom type. The document in PiplineOptionsFactory
> >> says
> >> "JSON format is required for all other types". If I want to use
> >> java.util.logging.Level in a getter and a setter, what JSON string
> should
> >> I
> >> pass in the command line?
> >>
> >> Thanks,
> >>
> >> Shen
> >>
> >>
> > --
> > Jean-Baptiste Onofré
> > jbono...@apache.org
> > http://blog.nanthrax.net
> > Talend - http://www.talend.com
> >
>

Reply via email to