@Test public void build() throws Exception { List<String> properties = Lists.newArrayList("id", "name", "age"); List<String> columns = Lists.newArrayList("id2", "name2", "age2"); CommonAddBuilder b = new CommonAddBuilder("id", properties, columns, true); assertThat(b.buildSql(), equalTo("insert into #table(name2, age2) values(:name, :age)")); properties = Lists.newArrayList("id", "name", "age"); columns = Lists.newArrayList("id2", "name2", "age2"); b = new CommonAddBuilder("id", properties, columns, false); assertThat(b.buildSql(), equalTo("insert into #table(id2, name2, age2) values(:id, :name, :age)")); }
@Override public String buildSql() { String s1 = Joiner.on(", ").join(columns); List<String> cps = new ArrayList<String>(); for (String prop : properties) { cps.add(":" + prop); } String s2 = Joiner.on(", ").join(cps); return String.format(SQL_TEMPLATE, s1, s2); }
CommonAddBuilder extends AbstractCommonBuilder { @Override public String buildSql() { String s1 = Joiner.on(", ").join(columns); List<String> cps = new ArrayList<String>(); for (String prop : properties) { cps.add(":" + prop); } String s2 = Joiner.on(", ").join(cps); return String.format(SQL_TEMPLATE, s1, s2); } }
CommonAddBuilder extends AbstractCommonBuilder { @Override public String buildSql() { String s1 = Joiner.on(", ").join(columns); List<String> cps = new ArrayList<String>(); for (String prop : properties) { cps.add(":" + prop); } String s2 = Joiner.on(", ").join(cps); return String.format(SQL_TEMPLATE, s1, s2); } CommonAddBuilder(String propId, List<String> props,
                          List<String> cols, boolean isAutoGenerateId); }
CommonAddBuilder extends AbstractCommonBuilder { @Override public String buildSql() { String s1 = Joiner.on(", ").join(columns); List<String> cps = new ArrayList<String>(); for (String prop : properties) { cps.add(":" + prop); } String s2 = Joiner.on(", ").join(cps); return String.format(SQL_TEMPLATE, s1, s2); } CommonAddBuilder(String propId, List<String> props,
                          List<String> cols, boolean isAutoGenerateId); @Override String buildSql(); }
CommonAddBuilder extends AbstractCommonBuilder { @Override public String buildSql() { String s1 = Joiner.on(", ").join(columns); List<String> cps = new ArrayList<String>(); for (String prop : properties) { cps.add(":" + prop); } String s2 = Joiner.on(", ").join(cps); return String.format(SQL_TEMPLATE, s1, s2); } CommonAddBuilder(String propId, List<String> props,
                          List<String> cols, boolean isAutoGenerateId); @Override String buildSql();  }