Skip to content

Commit

Permalink
Refactored by org.cftoolsuite.util.SimpleSourceRefactoringService on …
Browse files Browse the repository at this point in the history
…2024-08-27 12:09:53
  • Loading branch information
pacphi committed Aug 27, 2024
1 parent 6562b05 commit 599cd9e
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,56 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import lombok.Builder;
import lombok.Builder.Default;
import lombok.Getter;
public record AppUsageMonthly(
@JsonProperty("month") Integer month,
@JsonProperty("year") Integer year,
@JsonProperty("average_app_instances") Double averageAppInstances,
@JsonProperty("maximum_app_instances") Integer maximumAppInstances,
@JsonProperty("app_instance_hours") Double appInstanceHours
) {

@Builder
@Getter
@JsonPropertyOrder({"month", "year", "average_app_instances","maximum_app_instances", "app_instance_hours"})
public class AppUsageMonthly {
public static class AppUsageMonthlyBuilder {
private Integer month;
private Integer year;
private Double averageAppInstances;
private Integer maximumAppInstances;
private Double appInstanceHours;

@JsonProperty("month")
private Integer month;
public AppUsageMonthlyBuilder() {
this.averageAppInstances = 0.0;
this.maximumAppInstances = 0;
this.appInstanceHours = 0.0;
}

@JsonProperty("year")
private Integer year;
public AppUsageMonthlyBuilder month(Integer month) {
this.month = month;
return this;
}

@Default
@JsonProperty("average_app_instances")
private Double averageAppInstances = 0.0;
public AppUsageMonthlyBuilder year(Integer year) {
this.year = year;
return this;
}

@Default
@JsonProperty("maximum_app_instances")
private Integer maximumAppInstances = 0;
public AppUsageMonthlyBuilder averageAppInstances(Double averageAppInstances) {
this.averageAppInstances = averageAppInstances;
return this;
}

@Default
@JsonProperty("app_instance_hours")
private Double appInstanceHours = 0.0;
public AppUsageMonthlyBuilder maximumAppInstances(Integer maximumAppInstances) {
this.maximumAppInstances = maximumAppInstances;
return this;
}

public AppUsageMonthlyBuilder appInstanceHours(Double appInstanceHours) {
this.appInstanceHours = appInstanceHours;
return this;
}

public AppUsageMonthly build() {
return new AppUsageMonthly(month, year, averageAppInstances, maximumAppInstances, appInstanceHours);
}
}

@JsonCreator
public AppUsageMonthly(
Expand All @@ -45,4 +69,4 @@ public AppUsageMonthly(
this.appInstanceHours = appInstanceHours;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,45 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import lombok.Builder;
import lombok.Builder.Default;
import lombok.Getter;

@Builder
@Getter
@JsonPropertyOrder({"report_time", "monthly_reports", "yearly_reports"})
public class AppUsageReport {

@JsonProperty("report_time")
private String reportTime;
public record AppUsageReport(
@JsonProperty("report_time") String reportTime,
@JsonProperty("monthly_reports") List<AppUsageMonthly> monthlyReports,
@JsonProperty("yearly_reports") List<AppUsageYearly> yearlyReports) {

@Default
@JsonProperty("monthly_reports")
private List<AppUsageMonthly> monthlyReports = new ArrayList<>();
public AppUsageReport {
}

@Default
@JsonProperty("yearly_reports")
private List<AppUsageYearly> yearlyReports = new ArrayList<>();
public static class AppUsageReportBuilder {
private String reportTime;
private List<AppUsageMonthly> monthlyReports = new ArrayList<>();
private List<AppUsageYearly> yearlyReports = new ArrayList<>();

public AppUsageReportBuilder reportTime(String reportTime) {
this.reportTime = reportTime;
return this;
}

public AppUsageReportBuilder monthlyReports(List<AppUsageMonthly> monthlyReports) {
this.monthlyReports = monthlyReports;
return this;
}

public AppUsageReportBuilder yearlyReports(List<AppUsageYearly> yearlyReports) {
this.yearlyReports = yearlyReports;
return this;
}

public AppUsageReport build() {
return new AppUsageReport(reportTime, monthlyReports, yearlyReports);
}
}

@JsonCreator
public AppUsageReport(
public static AppUsageReport of(
@JsonProperty("report_time") String reportTime,
@JsonProperty("monthly_reports") List<AppUsageMonthly> monthlyReports,
@JsonProperty("yearly_reports") List<AppUsageYearly> yearlyReports) {
this.reportTime = reportTime;
this.monthlyReports = monthlyReports;
this.yearlyReports = yearlyReports;
return new AppUsageReport(reportTime, monthlyReports, yearlyReports);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,58 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import lombok.Builder;
import lombok.Builder.Default;
import lombok.Getter;

@Builder
@Getter
@JsonPropertyOrder({"year", "average_app_instances", "maximum_app_instances", "app_instance_hours"})
public class AppUsageYearly {

public record AppUsageYearly(
@JsonProperty("year")
private Integer year;

@Default
Integer year,
@JsonProperty("average_app_instances")
private Double averageAppInstances = 0.0;

@Default
Double averageAppInstances,
@JsonProperty("maximum_app_instances")
private Integer maximumAppInstances = 0;

@Default
Integer maximumAppInstances,
@JsonProperty("app_instance_hours")
private Double appInstanceHours = 0.0;
Double appInstanceHours
) {

@JsonCreator
public AppUsageYearly(
@JsonProperty("year") Integer year,
@JsonProperty("average_app_instances") Double averageAppInstances,
@JsonProperty("maximum_app_instances") Integer maximumAppInstances,
@JsonProperty("app_instance_hours") Double appInstanceHours) {
this.year = year;
this.averageAppInstances = averageAppInstances;
this.maximumAppInstances = maximumAppInstances;
this.appInstanceHours = appInstanceHours;
this(year, averageAppInstances == null ? 0.0 : averageAppInstances, maximumAppInstances == null ? 0 : maximumAppInstances, appInstanceHours == null ? 0.0 : appInstanceHours);
}

public static class AppUsageYearlyBuilder {
private Integer year;
private Double averageAppInstances;
private Integer maximumAppInstances;
private Double appInstanceHours;

public AppUsageYearlyBuilder year(Integer year) {
this.year = year;
return this;
}

public AppUsageYearlyBuilder averageAppInstances(Double averageAppInstances) {
this.averageAppInstances = averageAppInstances;
return this;
}

public AppUsageYearlyBuilder maximumAppInstances(Integer maximumAppInstances) {
this.maximumAppInstances = maximumAppInstances;
return this;
}

public AppUsageYearlyBuilder appInstanceHours(Double appInstanceHours) {
this.appInstanceHours = appInstanceHours;
return this;
}

public AppUsageYearly build() {
return new AppUsageYearly(year, averageAppInstances, maximumAppInstances, appInstanceHours);
}
}

}
public static AppUsageYearlyBuilder builder() {
return new AppUsageYearlyBuilder();
}
}

0 comments on commit 599cd9e

Please sign in to comment.