Java 인터페이스에서 Immutables (http://immutables.org)를 사용하여 빌더 및 불변 오브젝트를 생성 중입니다. @Primary (어떤 속성이 기본 필드인지 나타냄)라는 맞춤 메소드 레벨 주석을 작성했습니다.이 메소드는 변경 불가능한 인터페이스에서 내 메소드 중 하나에 주석을 달았습니다. 내가 immutables에 의해 만들어진 생성 된 자바 클래스에서 주석을 볼 수 없습니다. 나는 BYOA (Your Own Annotation) 가져 오기를 시도했지만 도움이되지 않습니다.Immutables를 사용할 때 인터페이스에서 생성 된 Java 클래스로 forward annotation을 수행하십시오.
생성 된 변경 불가능한 Java 클래스에 @Primary 주석을 가져 오는 방법이 있습니까?
UPDATE 지금
package-info.java
package com.mypackage;
import com.mercuria.recon.custom.annotation.Primary;
import org.immutables.value.Value;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.PACKAGE, ElementType.TYPE})
@Retention(RetentionPolicy.CLASS) // Make it class retention for incremental compilation
@Value.Style(passAnnotations=Primary.class)
public @interface MyStyle {}
차 주석에 따라 아래의 설정을
(아래 션의 제안을 바탕으로)
package com.mypackage.custom.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Primary {
}
package-info.json에서 MyStyle이 자체 파일에 선언되어야한다고하는 오류가 표시됩니다. 위의 구성이 맞는지 확실하지 않습니다. 내가 어디로 잘못 가고 있는지 조언 해 줄 수 있니?
package-info.json? 이 파일은 package-info.java라고합니다. 그리고 거기에 사용자 정의 주석을 정의해서는 안되며 패키지에 주석을 달아주세요. (내 대답 참조) –