Created
June 22, 2012 13:53
-
-
Save meza/2972860 to your computer and use it in GitHub Desktop.
User class
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
public class Greeter { | |
public String greetMessage(User user) { | |
if(StringUtils.isEmpty(user.email())) { | |
return null; | |
} | |
return "Hi, "+user.email(); | |
} | |
} |
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
public class GreetPrinter { | |
public void static main(String[] args) { | |
User user = new User(); | |
if (args.length > 1) { | |
user.setEmail(args[0]); | |
} | |
Greeter greeter = new Greeter(); | |
String msg = greeter.greetMessage(user); | |
if (msg != null) { | |
System.out.println(msg); | |
} | |
} | |
} |
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
public class User { | |
private String email; | |
public void setEmail(String email) { | |
this.email = email; | |
} | |
public String email() { | |
return email; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment