@Test public void testResolveInputValue() { doTestResolveInputValue("all provided", "foo", 2, "bar", "foo::2::bar"); doTestResolveInputValue("1, null, 3", "foo", null, "bar", "foo::null::bar"); doTestResolveInputValue("1, 2, null", "foo", 2, null, "foo::2::null"); doTestResolveInputValue("null, 2, null", null, 2, null, "null::2::null"); doTestResolveInputValue("isEmpty, null, 3", "", null, "bar", "::null::bar"); doTestResolveInputValue("null, null, null", null, null, null, null); doTestResolveInputValue("isEmpty, null, isEmpty", "", null, "", "::null::"); doTestResolveInputValue("invalid format", "foo", "not a number", "bar", null); }
@Override protected String resolveInputValue(final Row row) { int colCount = columns.size(); Object[] values = new Object[colCount]; boolean foundValue = false; for (int idx=0; idx < colCount; idx++) { values[idx] = columns.get(idx).getValue(row); foundValue = foundValue || values[idx] != null; } String fmtValue = null; if (foundValue) { try { fmtValue = String.format(format, values); } catch (IllegalFormatConversionException ifce) { fmtValue = null; } } return fmtValue; }
FormattedMultiColumnValue extends AbstractConvertingColumnValue<T> { @Override protected String resolveInputValue(final Row row) { int colCount = columns.size(); Object[] values = new Object[colCount]; boolean foundValue = false; for (int idx=0; idx < colCount; idx++) { values[idx] = columns.get(idx).getValue(row); foundValue = foundValue || values[idx] != null; } String fmtValue = null; if (foundValue) { try { fmtValue = String.format(format, values); } catch (IllegalFormatConversionException ifce) { fmtValue = null; } } return fmtValue; } }
FormattedMultiColumnValue extends AbstractConvertingColumnValue<T> { @Override protected String resolveInputValue(final Row row) { int colCount = columns.size(); Object[] values = new Object[colCount]; boolean foundValue = false; for (int idx=0; idx < colCount; idx++) { values[idx] = columns.get(idx).getValue(row); foundValue = foundValue || values[idx] != null; } String fmtValue = null; if (foundValue) { try { fmtValue = String.format(format, values); } catch (IllegalFormatConversionException ifce) { fmtValue = null; } } return fmtValue; } @JsonCreator  FormattedMultiColumnValue(@JsonProperty("columns") final List<ColumnValue<?>> cols,
                                     @JsonProperty("format") final String fmt,
                                     @JsonProperty(value="xform", required=false) final ValueTransformer<T> xform,
                                     @JsonProperty(value="multiKey", required=false) final String multiKey); }
FormattedMultiColumnValue extends AbstractConvertingColumnValue<T> { @Override protected String resolveInputValue(final Row row) { int colCount = columns.size(); Object[] values = new Object[colCount]; boolean foundValue = false; for (int idx=0; idx < colCount; idx++) { values[idx] = columns.get(idx).getValue(row); foundValue = foundValue || values[idx] != null; } String fmtValue = null; if (foundValue) { try { fmtValue = String.format(format, values); } catch (IllegalFormatConversionException ifce) { fmtValue = null; } } return fmtValue; } @JsonCreator  FormattedMultiColumnValue(@JsonProperty("columns") final List<ColumnValue<?>> cols,
                                     @JsonProperty("format") final String fmt,
                                     @JsonProperty(value="xform", required=false) final ValueTransformer<T> xform,
                                     @JsonProperty(value="multiKey", required=false) final String multiKey); @Override int getSortColumn(); @JsonProperty("columns") final List<ColumnValue<?>> getColumns(); @JsonProperty("format") final String getFormat(); }
FormattedMultiColumnValue extends AbstractConvertingColumnValue<T> { @Override protected String resolveInputValue(final Row row) { int colCount = columns.size(); Object[] values = new Object[colCount]; boolean foundValue = false; for (int idx=0; idx < colCount; idx++) { values[idx] = columns.get(idx).getValue(row); foundValue = foundValue || values[idx] != null; } String fmtValue = null; if (foundValue) { try { fmtValue = String.format(format, values); } catch (IllegalFormatConversionException ifce) { fmtValue = null; } } return fmtValue; } @JsonCreator  FormattedMultiColumnValue(@JsonProperty("columns") final List<ColumnValue<?>> cols,
                                     @JsonProperty("format") final String fmt,
                                     @JsonProperty(value="xform", required=false) final ValueTransformer<T> xform,
                                     @JsonProperty(value="multiKey", required=false) final String multiKey); @Override int getSortColumn(); @JsonProperty("columns") final List<ColumnValue<?>> getColumns(); @JsonProperty("format") final String getFormat();  }