Created
May 14, 2013 08:26
-
-
Save YukiYoshikawa/5574486 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
package trial.yy.lombok.client; | |
import static java.lang.System.out; | |
import lombok.Getter; | |
import lombok.Setter; | |
/** | |
* Created with Eclipse. | |
* User: yy | |
*/ | |
public class LombokClient1 { | |
/** | |
* Beanクラス | |
*/ | |
public static class Person { | |
/** 名前 */ | |
@Getter | |
private String name ="DEFAULT_NAME"; | |
/** 年齢 */ | |
@Getter @Setter | |
private int age; | |
} | |
public static void main(String[] args) { | |
Person person1 = new Person(); | |
// 対象クラスでsetterを記述してないのにsetterが使える!! | |
person1.setAge(12); | |
// person1.setName("Taro"); ← nameには@Setterを指定しないのでコンパイルエラー | |
// 対象クラスでgetterを記述してないのにgetterが使える!! | |
out.println("age: " + person1.getAge()); | |
out.println("name: " + person1.getName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment