@Test public void shouldGetParsedValueForBooleanDataType() throws Exception { parameter.setDataType("java.lang.Boolean"); assertThat(parameter.getParsedValueOf("true"), is((Object) true)); }
public Object getParsedValueOf(String value) throws ParseException { Object objectValue = value; switch (this.getDataType()) { case INTEGER: objectValue = Integer.parseInt(value); break; case SHORT: objectValue = Short.parseShort(value); break; case LONG: objectValue = Long.parseLong(value); break; case BOOLEAN: objectValue = Boolean.parseBoolean(value); break; case DATE: SimpleDateFormat clientFormat = new SimpleDateFormat("dd/MM/yy"); Date dateInClientFormat = clientFormat.parse(value); SimpleDateFormat dbFormat = new SimpleDateFormat("yyyy-MM-dd"); objectValue = dbFormat.parse(dbFormat.format(dateInClientFormat)); break; case FLOAT: objectValue = Float.parseFloat(value); break; case DOUBLE: objectValue = Double.parseDouble(value); break; case BIG_DECIMAL: objectValue = BigDecimal.valueOf(Double.parseDouble(value)); break; } return objectValue; }
TemplateParameter extends BaseModel { public Object getParsedValueOf(String value) throws ParseException { Object objectValue = value; switch (this.getDataType()) { case INTEGER: objectValue = Integer.parseInt(value); break; case SHORT: objectValue = Short.parseShort(value); break; case LONG: objectValue = Long.parseLong(value); break; case BOOLEAN: objectValue = Boolean.parseBoolean(value); break; case DATE: SimpleDateFormat clientFormat = new SimpleDateFormat("dd/MM/yy"); Date dateInClientFormat = clientFormat.parse(value); SimpleDateFormat dbFormat = new SimpleDateFormat("yyyy-MM-dd"); objectValue = dbFormat.parse(dbFormat.format(dateInClientFormat)); break; case FLOAT: objectValue = Float.parseFloat(value); break; case DOUBLE: objectValue = Double.parseDouble(value); break; case BIG_DECIMAL: objectValue = BigDecimal.valueOf(Double.parseDouble(value)); break; } return objectValue; } }
TemplateParameter extends BaseModel { public Object getParsedValueOf(String value) throws ParseException { Object objectValue = value; switch (this.getDataType()) { case INTEGER: objectValue = Integer.parseInt(value); break; case SHORT: objectValue = Short.parseShort(value); break; case LONG: objectValue = Long.parseLong(value); break; case BOOLEAN: objectValue = Boolean.parseBoolean(value); break; case DATE: SimpleDateFormat clientFormat = new SimpleDateFormat("dd/MM/yy"); Date dateInClientFormat = clientFormat.parse(value); SimpleDateFormat dbFormat = new SimpleDateFormat("yyyy-MM-dd"); objectValue = dbFormat.parse(dbFormat.format(dateInClientFormat)); break; case FLOAT: objectValue = Float.parseFloat(value); break; case DOUBLE: objectValue = Double.parseDouble(value); break; case BIG_DECIMAL: objectValue = BigDecimal.valueOf(Double.parseDouble(value)); break; } return objectValue; } TemplateParameter(Long templateId
                           , String name
                           , String displayName
                           , String defaultValue
                           , String dataType
                           , String selectSql
                           , String description ); }
TemplateParameter extends BaseModel { public Object getParsedValueOf(String value) throws ParseException { Object objectValue = value; switch (this.getDataType()) { case INTEGER: objectValue = Integer.parseInt(value); break; case SHORT: objectValue = Short.parseShort(value); break; case LONG: objectValue = Long.parseLong(value); break; case BOOLEAN: objectValue = Boolean.parseBoolean(value); break; case DATE: SimpleDateFormat clientFormat = new SimpleDateFormat("dd/MM/yy"); Date dateInClientFormat = clientFormat.parse(value); SimpleDateFormat dbFormat = new SimpleDateFormat("yyyy-MM-dd"); objectValue = dbFormat.parse(dbFormat.format(dateInClientFormat)); break; case FLOAT: objectValue = Float.parseFloat(value); break; case DOUBLE: objectValue = Double.parseDouble(value); break; case BIG_DECIMAL: objectValue = BigDecimal.valueOf(Double.parseDouble(value)); break; } return objectValue; } TemplateParameter(Long templateId
                           , String name
                           , String displayName
                           , String defaultValue
                           , String dataType
                           , String selectSql
                           , String description ); Object getParsedValueOf(String value); }
TemplateParameter extends BaseModel { public Object getParsedValueOf(String value) throws ParseException { Object objectValue = value; switch (this.getDataType()) { case INTEGER: objectValue = Integer.parseInt(value); break; case SHORT: objectValue = Short.parseShort(value); break; case LONG: objectValue = Long.parseLong(value); break; case BOOLEAN: objectValue = Boolean.parseBoolean(value); break; case DATE: SimpleDateFormat clientFormat = new SimpleDateFormat("dd/MM/yy"); Date dateInClientFormat = clientFormat.parse(value); SimpleDateFormat dbFormat = new SimpleDateFormat("yyyy-MM-dd"); objectValue = dbFormat.parse(dbFormat.format(dateInClientFormat)); break; case FLOAT: objectValue = Float.parseFloat(value); break; case DOUBLE: objectValue = Double.parseDouble(value); break; case BIG_DECIMAL: objectValue = BigDecimal.valueOf(Double.parseDouble(value)); break; } return objectValue; } TemplateParameter(Long templateId
                           , String name
                           , String displayName
                           , String defaultValue
                           , String dataType
                           , String selectSql
                           , String description ); Object getParsedValueOf(String value); static final String INTEGER; static final String SHORT; static final String LONG; static final String BOOLEAN; static final String DATE; static final String FLOAT; static final String DOUBLE; static final String BIG_DECIMAL; }