IT/WEB

[JAVA] lombok @Getter, @Setter 제외하고 따로 getter 만들기

오달달씨 2022. 7. 20. 14:51
728x90
반응형

lombok @Getter, @Setter 어노테이션 제외하고 따로 getter 만들기

 

@Entity
@DynamicUpdate
@Data
public class entity {
	@Column(name = "TOTAL")
    private String total;
    
    @Column(name = "SUCCESS")
    private String success;
    
    @Column(name = "ERROR")
    private String error;
    
    public String getPercentile() {
        String percentile = String.format("%.2f", Double.parseDouble(this.success) / Double.parseDouble(this.total)*100.0);
        return percentile+"%";
    }
}
@Entity
@DynamicUpdate
@Data
public class entity {
	@Column(name = "COUNT")
    private int count;
    
    @Column(name = "SUCCESS")
    private int success;
    
    @Column(name = "ERROR")
    private int error;
    
     public String getPercentile() {
        String percentile = String.format("%.2f", (double) this.success / (double) this.count *100.0);
        return percentile+"%";
    }
}
728x90
반응형