Created
September 11, 2017 16:28
-
-
Save adam-arold/6e2b6932521ca83ae8e156ce016d9a3a to your computer and use it in GitHub Desktop.
List presenter decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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