@Test public void testConditionFormat() { String expected = "date_str>='20190710' and date_str<'20190711'"; String condition = "date_str>='${start_date}' and date_str<'${end_date}'"; String fmtCondition = formatter.formatSentence(condition); assertEquals(expected, fmtCondition); }
String formatSentence(String sentence) { String[] cArray = REG_PATTERN.split(sentence); StringBuilder sbr = new StringBuilder(); List<String> keys = getKeys(sentence); int length = Math.max(cArray.length, keys.size()); for (int i = 0; i < length; i++) { if (i < cArray.length) { sbr.append(cArray[i]); } if (i < keys.size()) { sbr.append(getValue(keys.get(i))); } } return sbr.toString(); }
JoinedFormatter { String formatSentence(String sentence) { String[] cArray = REG_PATTERN.split(sentence); StringBuilder sbr = new StringBuilder(); List<String> keys = getKeys(sentence); int length = Math.max(cArray.length, keys.size()); for (int i = 0; i < length; i++) { if (i < cArray.length) { sbr.append(cArray[i]); } if (i < keys.size()) { sbr.append(getValue(keys.get(i))); } } return sbr.toString(); } }
JoinedFormatter { String formatSentence(String sentence) { String[] cArray = REG_PATTERN.split(sentence); StringBuilder sbr = new StringBuilder(); List<String> keys = getKeys(sentence); int length = Math.max(cArray.length, keys.size()); for (int i = 0; i < length; i++) { if (i < cArray.length) { sbr.append(cArray[i]); } if (i < keys.size()) { sbr.append(getValue(keys.get(i))); } } return sbr.toString(); } JoinedFormatter();   JoinedFormatter(IJoinedFlatTableDesc flatDesc); }
JoinedFormatter { String formatSentence(String sentence) { String[] cArray = REG_PATTERN.split(sentence); StringBuilder sbr = new StringBuilder(); List<String> keys = getKeys(sentence); int length = Math.max(cArray.length, keys.size()); for (int i = 0; i < length; i++) { if (i < cArray.length) { sbr.append(cArray[i]); } if (i < keys.size()) { sbr.append(getValue(keys.get(i))); } } return sbr.toString(); } JoinedFormatter();   JoinedFormatter(IJoinedFlatTableDesc flatDesc); Object getValue(String key); }
JoinedFormatter { String formatSentence(String sentence) { String[] cArray = REG_PATTERN.split(sentence); StringBuilder sbr = new StringBuilder(); List<String> keys = getKeys(sentence); int length = Math.max(cArray.length, keys.size()); for (int i = 0; i < length; i++) { if (i < cArray.length) { sbr.append(cArray[i]); } if (i < keys.size()) { sbr.append(getValue(keys.get(i))); } } return sbr.toString(); } JoinedFormatter();   JoinedFormatter(IJoinedFlatTableDesc flatDesc); Object getValue(String key);  }