Skip to content

Instantly share code, notes, and snippets.

@YukiYoshikawa
Created May 14, 2013 08:26
Show Gist options
  • Save YukiYoshikawa/5574486 to your computer and use it in GitHub Desktop.
Save YukiYoshikawa/5574486 to your computer and use it in GitHub Desktop.
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