Created
September 19, 2013 00:24
-
-
Save kinow/6617618 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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