[자바 개발 도구 롬복] 일반적인 프리젠 테이션 노트

과거에는 개체 모델 코드, 우리는 그래서 다른 생성자와 왕창뿐만 아니라 설정 가져 오기를 / 작성해야 할 때. 롬복은 우리를 위해 아주 좋은 플러그인을 제공합니다.
대부분의 프로젝트에서는, 당신은 당신이를 참조하십시오, 더 많은 옵션을 볼 필요가있는 경우, 충분한 다음 중앙 주석을 사용할 필요가 : 포털

  1. @Getter
  2. @Setter
  3. @ToString
  4. @RequiredArgsConstructor 최종 필드 생성자를 생성
      /**
       * java class
       */
      @RequiredArgsConstructor
      class UserVO {
          private final Integer id;
          private final String name;
          private int age;
      }
      
      /**
       * 编译后生成的代码
       */
      class UserVO {
          private final Integer id;
          private final String name;
          private int age;
      
          public UserVO(Integer id, String name) {
              this.id = id;
              this.name = name;
          }
    }
  1. @Data 조합 코멘트
  /**
   * @see Getter
   * @see Setter
   * @see RequiredArgsConstructor
   * @see ToString
   * @see EqualsAndHashCode
   * @see lombok.Value
   */
  @Target(ElementType.TYPE)
  @Retention(RetentionPolicy.SOURCE)
  public @interface Data {
      /**
       * ...
       */
      String staticConstructor() default "";
  }
  1. @Builder 원래 할당 모드를 변경
  • 전에 사용
    UTOOLS1563926459568.png
  • 사용 후 (빌더 패턴을 널리 척하기 소스 코드에서 사용되었다)
    UTOOLS1563926487313.png
  1. @Slf4j 람에 해당 구비
    public static final Logger LOGGER =
        LoggerFactory.getLogger(UserCenterApplication.class);
/**
 * This annotation is valid for classes and enumerations.<br>
 * @see <a href="https://www.slf4j.org/api/org/slf4j/Logger.html">org.slf4j.Logger</a>
 * @see <a href="https://www.slf4j.org/api/org/slf4j/LoggerFactory.html#getLogger(java.lang.Class)">org.slf4j.LoggerFactory#getLogger(java.lang.Class)</a>
 * @see lombok.extern.apachecommons.CommonsLog &#64;CommonsLog
 * @see lombok.extern.java.Log &#64;Log
 * @see lombok.extern.log4j.Log4j &#64;Log4j
 * @see lombok.extern.log4j.Log4j2 &#64;Log4j2
 * @see lombok.extern.slf4j.XSlf4j &#64;XSlf4j
 * @see lombok.extern.jbosslog.JBossLog &#64;JBossLog
 * @see lombok.extern.flogger.Flogger &#64;Flogger
 */
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface Slf4j {
    /** @return The category of the constructed Logger. By default, it will use the type where the annotation is placed. */
    String topic() default "";
}

추천

출처www.cnblogs.com/zhangpan1244/p/11241486.html