我有一个记录,想向它添加默认构造函数。
public record Record(int recordId) {
   public Record {
   }
}
Run Code Online (Sandbox Code Playgroud)
但它用int参数创建了构造函数。
public final class Record extends java.lang.Record {
    private final int recordId;
    public Record(int);
    //other method
}
Run Code Online (Sandbox Code Playgroud)
我们如何向记录添加默认构造函数?
这可能是一个重复的这个,但没有得到那边妥善解决。我有如下对象,
var replyDataObj = {
                  "department": {
                    "name": getCache("departmentName")
                  },
                  "subject": replyEmailSubject,  
                  "payload": {
                    "email": {
                      "contents": {
                        "content": [
                          {
                            "type": "html",
                            "value": replyEmailContent
                          }   
                        ]
                      },
                      "emailAddresses": {
                        "from": fromEmailId,
                        "to": {
                          "address": [
                            toEmailId
                          ]
                        }        
                      }
                    }
                  }  
            }
Run Code Online (Sandbox Code Playgroud)
我想根据 cc 字段是否存在,动态地将以下键值添加到 'emailAddresses' 键,
"cc": {
         "address": [
           ccEmailId
          ]
      }  
Run Code Online (Sandbox Code Playgroud)
所以它看起来像,
var replyDataObj = {
              "department": {
                "name": getCache("departmentName")
              },
              "subject": replyEmailSubject,  
              "payload": {
                "email": {
                  "contents": {
                    "content": [
                      {
                        "type": "html", …Run Code Online (Sandbox Code Playgroud)