簡體   English   中英

在 Eclipse 中使用 Objects.requireNonNull(T obj) 使用包括空檢查在內的字段生成構造函數?

[英]Generate constructor using fields including null check using Objects.requireNonNull(T obj) in Eclipse?

構造函數可以很容易地在 eclipse 中生成。 但是,能否以某種方式生成也執行空檢查的構造函數? 例子:

public class A {

    private B b;

    private C c;

    //I need to auto-generate this type of constructor for many of my classes in Eclipse  
    public A(B b, C c) {
         this.b = Objects.requireNonNull(b);
         this.c = Objects.requireNonNull(c); 
    }

}

這可能嗎?

請參閱以下教程:

鏈接1鏈路2

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM