Skip to content

Instantly share code, notes, and snippets.

@adam-arold
Created September 11, 2017 16:28
Show Gist options
  • Save adam-arold/6e2b6932521ca83ae8e156ce016d9a3a to your computer and use it in GitHub Desktop.
Save adam-arold/6e2b6932521ca83ae8e156ce016d9a3a to your computer and use it in GitHub Desktop.
List presenter decorator
public class ListPresenterDecorator<T> extends AbstractList<T> {
private List<T> list;
public ListPresenterDecorator(List<T> list) {
this.list = list;
}
public String present() {
return list.stream()
.map(Object::toString)
.collect(Collectors.joining(", "));
}
@Override
public T get(int index) {
return list.get(index);
}
@Override
public int size() {
return list.size();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment