Skip to content

Instantly share code, notes, and snippets.

@kinow
Created September 19, 2013 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinow/6617618 to your computer and use it in GitHub Desktop.
Save kinow/6617618 to your computer and use it in GitHub Desktop.
class ContainerAdapter implements Procedure<String> {
private Collection<String> containments = new ArrayList<String>();
protected Container container;
public ContainerAdapter(Container adaptee) {
this.container = adaptee;
}
public void run(String obj) {
this.containments.add(obj.toUpperCase());
}
public Collection<String> getContainments() {
EachElement.from(container.getContainments()).run(this);
return this.containments;
}
}
public class Container {
protected Collection<String> containments = new ArrayList<String>();
public Collection<String> getContainments() {
return containments;
}
public static void main(String[] args) {
Container container = new Container();
container.getContainments().addAll(Arrays.asList("banana", "abacate", "abacaxi", "maracuja"));
System.out.println(container.getContainments());
ContainerAdapter adapter = new ContainerAdapter(container);
System.out.println(adapter.getContainments());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment