Skip to content

Commit 49a9869

Browse files
committed
implement CR feedback
1 parent 2e92477 commit 49a9869

35 files changed

Lines changed: 420 additions & 245 deletions

File tree

modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/RFC3339DateFormat.mustache

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515
16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

samples/openapi3/server/petstore/spring-boot-oneof-interface/src/main/java/org/openapitools/RFC3339DateFormat.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515

16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

samples/openapi3/server/petstore/spring-boot-oneof-sealed/src/main/java/org/openapitools/RFC3339DateFormat.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515

16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/RFC3339DateFormat.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515

16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/RFC3339DateFormat.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515

16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/RFC3339DateFormat.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515

16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/RFC3339DateFormat.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515

16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/RFC3339DateFormat.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515

16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/RFC3339DateFormat.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515

16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/RFC3339DateFormat.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ public class RFC3339DateFormat extends DateFormat {
1313
private static final long serialVersionUID = 1L;
1414
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1515

16-
private final StdDateFormat fmt = new StdDateFormat()
17-
.withTimeZone(TIMEZONE_Z)
18-
.withColonInTimeZone(true);
19-
2016
public RFC3339DateFormat() {
2117
this.calendar = new GregorianCalendar();
18+
this.calendar.setTimeZone(TIMEZONE_Z);
2219
}
2320

2421
@Override
2522
public Date parse(String source, ParsePosition pos) {
26-
return fmt.parse(source, pos);
23+
return createFormatter().parse(source, pos);
2724
}
2825

2926
@Override
3027
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
31-
return fmt.format(date, toAppendTo, fieldPosition);
28+
return createFormatter().format(date, toAppendTo, fieldPosition);
29+
}
30+
31+
private StdDateFormat createFormatter() {
32+
return new StdDateFormat()
33+
.withTimeZone(TIMEZONE_Z)
34+
.withColonInTimeZone(true);
3235
}
3336

3437
@Override
3538
public Object clone() {
36-
return this;
39+
RFC3339DateFormat clone = (RFC3339DateFormat) super.clone();
40+
clone.calendar = (GregorianCalendar) this.calendar.clone();
41+
return clone;
3742
}
3843
}

0 commit comments

Comments
 (0)