java - How to set a default value for boolean field in a model class for Camel Bindy -


i'm using bindy map csv file data given model class. whole process works fine, except default value of boolean field. field not part of csv file, necessary in model class further processes. have set default value true, "ignored" , field set false if run camel route.

this snippet of model class:

@csvrecord(separator = " ", skipfirstline = false) public class mymodel {    // ... more data fields    @datafield(pos = 8, defaultvalue = "true")   public boolean approved; 

defaultvalue expects string value can't set boolean.true. tried other values "true", "yes", "y" , "1" no luck.

the source of bindycsvfactory says class format used set default value, seems can't handle boolean fields , uses default of boolean instead , false.

the locale set "en_us" using command:

bindycsvdataformat format = new bindycsvdataformat("[model package]"); format.setlocale("en_us"); 

so main question is: how set default value of boolean field true in bindy managed model class?

you can't. if have @ formatfactory code (http://camel.apache.org/maven/camel-2.11.0/camel-bindy/apidocs/src-html/org/apache/camel/dataformat/bindy/formatfactory.html) can see doesn't support booleans.

it looks choices either

  • remove @datafield annotation , initialise boolean public boolean approved = true. you'll have add in later once approved field added input file.
  • read column string or integer , convert boolean in code.

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -