Skip to content

Instantly share code, notes, and snippets.

@uklance
Last active August 29, 2015 13:57
Show Gist options
  • Save uklance/9617036 to your computer and use it in GitHub Desktop.
Save uklance/9617036 to your computer and use it in GitHub Desktop.
public class ConverterGridDataSource implements GridDataSource {
private final GridDataSource delegate;
private final Converter converter;
public ConverterGridDataSource(GridDataSource delegate, Converter converter) {
this.delegate = delegate;
this.converter = converter;
}
public int getAvailableRows() {
return delegate.getAvailableRows();
}
public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints) {
delegate.prepare(startIndex, endIndex, sortConstraints);
}
public Object getRowValue(int index) {
return converter.convert(delegate.getRowValue(index));
}
public Class getRowType() {
return converter.getType();
}
}
public interface Converter<T> {
T convert(Object o);
Class<T> getType();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment