@NonNull
NEW in Lombok 0.11.10: You can use @NonNull
on the parameter of a method or constructor to have lombok generate a null-check statement for you.
@NonNull을 메소드의 파라미터나 생성자에 사용하면 null-check statement를 만들어줌.
if (param == null) throw new NullPointerException("param"); 와 같은 역할을 함.
@Getter
,
@Setter
You can annotate any field with @Getter
and/or @Setter
, to let lombok generate the default getter/setter automatically.
getter,setter 자동으로 생성.
@ToString
Any class definition may be annotated with @ToString
to let lombok generate an implementation of the toString()
method. By default, it'll print your class name, along with each field, in order, separated by commas.
어떤 클래스던 @tostring을 쓴다면 lombok이 tostring() 메소드를 만든다. 기본적으로 클래스 이름, 각자의 필드와 더불어서 순서대로 ',' 에 의해 분류된다.
By default, all non-static fields will be printed. If you want to skip some fields, you can name them in the exclude
parameter
기본적으로 모든 static이 아닌 필드는 출력된다. 어떤 필드를 스킵하고 싶으면 exclude 파라미터를 사용하면 된다.
ex> @ToString(exclude="id)
callSuper
to true, you can include the output of the superclass implementation of toString
to the output. Be aware that the default implementation of toString()
in java.lang.Object
is pretty much meaningless, so you probably don't want to do this unless you are extending another class.
ex> @ToString(callSuper=true, includeFieldNames=true) n
@EqualsAndHashCode
to let lombok generate implementations of the equals(Object other)
and hashCode()
methods. By default, it'll use all non-static, non-transient fields, but you can exclude more fields by naming them in the optional exclude
parameter to the annotation. callSuper
to true when you don't extend anything (you extend java.lang.Object
) is a compile-time error, because it would turn the generated equals()
and hashCode()
implementations into having the same behaviour as simply inheriting these methods from java.lang.Object
: only the same object will be equal to each other and will have the same hashCode.@NoArgsConstructor
will generate a constructor with no parameters. If this is not possible (because of final fields), a compiler error will result instead. For fields with constraints, such as @NonNull
fields, no check or assignment is generated, so be aware that these constraints may then not be fulfilled until those fields are properly initialized later. Certain java constructs, such as hibernate and the Service Provider Interface require a no-args constructor. This annotation is useful primarily in combination with either @Data
or one of the other constructor generating annotations.@Data
is like having implicit @Getter
, @Setter
, @ToString
, @EqualsAndHashCode
and @RequiredArgsConstructor
@Getter
, @Setter
, @ToString
, @EqualsAndHashCode
and @RequiredArgsConstructor 가 모두 포함되어있음.
@CommonsLog
private static final org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(LogExample.class);
@CommonLog를 쓰면 자동으로 위에 코드가 써지고 log.debug(); 로 코드를 쓸 수 있음.
'개발' 카테고리의 다른 글
웹페이지 한글 출력,servlet 한글 출력,물음표 표시 해결, 웹 브라우져에 따른 파라미터 처리,오라클 케릭터셋-2 (0) | 2015.05.10 |
---|---|
톰켓 한글 setCharacterEncoding 안되는 이유, jsp,servlet 한글 인코딩 문제, 웹 브라우져에 따른 파라미터 처리방식-1 (0) | 2015.05.10 |
자바 리플렉션 사용법 , Reflection (0) | 2015.05.10 |
스프링 다국어 처리. spring Locale setting. (0) | 2015.05.10 |
QueryDsl에서 uniqueResult, singleResult 차이점. (0) | 2015.05.07 |