Created
April 16, 2012 16:02
-
-
Save grimrose/2399667 to your computer and use it in GitHub Desktop.
簡易メモ
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 interface Finder { | |
List<String> find() | |
} | |
class A_Finder implements Finder { | |
List<String> find() { | |
[ "1","2" ] | |
} | |
} | |
class B_Finder implements Finder { | |
List<String> find() { | |
[ "3","4" ] | |
} | |
} | |
class Human { | |
void execute(String type) { | |
getFinder(type).find().each { println it } | |
} | |
Finder getFinder(String type) { | |
switch (type) { | |
case "A" : return new A_Finder() | |
case "B" : return new B_Finder() | |
default : null | |
} | |
} | |
} | |
Human h = new Human(); | |
h.execute("A") | |
h.execute("B") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment