표준애너테이션과 메타애너테이션
표준애너테이션은 사전에 정의된 애너테이션들을 의미한다.
메타애너테이션은 애너테이션을 정의할때 사용하는 애너테이션으로 메타데이터를 제공하거나 사용방법/범위 등을 지정한다.
표준애너테이션
@Override
https://standout.tistory.com/160
덮어쓰는 annotation, @Override
@ annotation 컴파일 주석기호 @Override 재정의, 부모의 말을 덮어쓰기/거역하다로 이해해보자. 인터페이스등을 implements하면 자주 보게 될것이다. VIP고객에게 일반고객과 같은 안내문자를 보내지만
standout.tistory.com
@Deprecated
https://standout.tistory.com/1406
Annotation - @Deprecated
@Deprecated 해당 요소(클래스, 메서드, 필드 등)가 더 이상 권장되지 않음을 나타낸다. 새로운 코드에서는 사용하지 않는 것이 좋다. class DeprecatedExample { @Deprecated void oldMethod() { // 구현 내용 } }
standout.tistory.com
@SuppressWarnings
https://standout.tistory.com/1407
Annotation - @SuppressWarnings
@SuppressWarnings 특정 경고 메시지를 무시하도록 컴파일러에 지시합니다. class SuppressWarningExample { @SuppressWarnings("unchecked") void uncheckedMethod() { // 제네릭 타입 안정성 경고를 무시하는 예시 List list = new
standout.tistory.com
@SafeVarargs
https://standout.tistory.com/1408
Annotation - @SafeVarargs
@SafeVarargs 메서드에 대한 가변인자(varargs) 매개변수가 안전하다는 것을 나타냅니다. 가변인자와 관련된 경고를 억제합니다. class SafeVarargsExample { @SafeVarargs final void process(List... lists) { for (List list :
standout.tistory.com
@FunctionalInterface
https://standout.tistory.com/1409
Annotation - @FunctionalInterface
@FunctionalInterface 해당 인터페이스가 함수형 인터페이스임을 나타냅니다. 즉, 하나의 추상 메서드만을 가지고 있어야 합니다. @FunctionalInterface interface MathOperation { int operation(int a, int b); }
standout.tistory.com
@Native
https://standout.tistory.com/1410
Annotation - @Native
@Native 네이티브 메서드를 나타냅니다. 즉, 네이티브 코드(일반적으로 다른 언어로 작성된 코드)를 호출하는 메서드임을 나타냅니다. 자바 네이티브 인터페이스(JNI)를 사용할 때 주로 활용됩니다
standout.tistory.com
메타애너테이션
@Target
https://standout.tistory.com/1411
Annotation - @Target
@Target 애너테이션을 적용할 수 있는 대상(타겟)을 지정한다. 예를 들어, 클래스, 메서드, 필드 등에 애너테이션을 적용할 수 있는 대상을 명시할 수 있습니다. import java.lang.annotation.ElementType; import
standout.tistory.com
@Documented
https://standout.tistory.com/1412
Annotation - @Documented
@Documented 애너테이션에 대한 문서를 생성할 때 해당 애너테이션 정보를 포함시키도록 지정한다. 즉, 해당 애너테이션을 사용하는 클래스나 메서드의 문서화에 애너테이션 정보가 포함됩니다. im
standout.tistory.com
@Inherited
https://standout.tistory.com/1413
Annotation - @Inherited
@Inherited 부모 클래스에서 애너테이션이 상속되도록 지정한다. 즉, 부모 클래스에 적용된 애너테이션은 자식 클래스에도 자동으로 적용됩니다. import java.lang.annotation.Inherited; @Inherited @interface MyAnn
standout.tistory.com
@Retention
https://standout.tistory.com/1414
Annotation - @Retention
@Retention 애너테이션이 유지되는 기간을 지정한다. 소스 코드, 클래스 파일, 런타임 시점 중 어느 시점까지 애너테이션 정보를 유지할 것인지를 설정할 수 있습니다. import java.lang.annotation.Retention;
standout.tistory.com
@Repeatable
https://standout.tistory.com/1415
Annotation - @Repeatable
@Repeatable 같은 애너테이션을 여러 번 사용할 수 있도록 허용한다. Java 8부터 도입되었습니다. import java.lang.annotation.Repeatable; @Repeatable(MyAnnotations.class) @interface MyAnnotation { // 애너테이션 내용 } @inter
standout.tistory.com
'이론' 카테고리의 다른 글
하나의 추상 메서드를 갖는, 함수형 인터페이스 (0) | 2024.02.27 |
---|---|
annotation이란? (0) | 2024.02.15 |
PM2, 애플리케이션을 관리하고 실행하는 프로세스 매니저 (0) | 2024.02.14 |
npm 패키지매니저: 외부 라이브러리나 모듈을 쉽게 설치하고 관리 (0) | 2024.02.14 |
자바의 정석 Chapter11: 컬렉션 프레임웍 (0) | 2024.02.06 |