package com.njust.test.json;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonIgnore;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
public class Project
{
    @Getter
    private String name;

    /**
     * 1.需要提供get方法
     */
    @Getter
    private Date startDate;

    @Getter
    private String password;

    public Project(String name, Date startDate, String password)
    {
        this.name = name;
        this.startDate = startDate;
        this.password = password;
    }

    /**
     * 2.只要提供了get方法，就算没有对应的属性，也会进行json转换
     *
     * @return
     */
    public String getFormatedStartDate()
    {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return simpleDateFormat.format(startDate);
    }

    /**
     * 3.避免密码泄露，所以复写get方法来避免内容被打印
     *
     * @return
     */
    public String getPassword()
    {
        return "password";
    }

    /**
     * 4.避免get方法就会出现在json后的字段中，进行ignore标识
     *
     * @return
     */
    @JsonIgnore
    public String getRealPassword()
    {
        return this.password;
    }

}

@@ -884,177 +884,35 @@
 %E7%A0%81%E6%B3%84%E9%9C%B2%EF%BC%8C
-%E6%89%80%E4%BB%A5%E5%A4%8D%E5%86%99get%E6%96%B9%E6%B3%95%E6%9D%A5%E9%81%BF%E5%85%8D%E5%86%85%E5%AE%B9%E8%A2%AB%E6%89%93%E5%8D%B0%0A     *%0A     * @return%0A     */%0A    public String getPassword()%0A    %7B%0A        return %22password%22;%0A    %7D%0A%0A    /**%0A     * 4.%E9%81%BF%E5%85%8Dget%E6%96%B9%E6%B3%95%E5%B0%B1%E4%BC%9A%E5%87%BA%E7%8E%B0%E5%9C%A8json%E5%90%8E%E7%9A%84%E5%AD%97%E6%AE%B5%E4%B8%AD%EF%BC%8C%E8%BF%9B%E8%A1%8Cignore%E6%A0%87%E8%AF%86
+json%E6%A0%BC%E5%BC%8F%E5%8C%96%E6%97%B6%E4%B8%8D%E6%89%93%E5%8D%B0%EF%BC%8C%E4%BD%86%E6%98%AF%E5%85%A5%E5%BA%93%E7%AD%89%E6%93%8D%E4%BD%9C%E6%97%B6%E8%BF%98%E8%AF%B4%E6%AD%A3%E7%A1%AE%E8%AF%BB%E5%8F%96%E7%9A%84
 %0A   
@@ -979,12 +979,8 @@
  get
-Real
 Pass

Update Project.java