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é <[email protected]>
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é
> [email protected]
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>