Skip to content

Commit 68bf538

Browse files
committed
Cache format enum of TimestampFormatTrait
This makes it so we don't have to scan this over and over in smithy-java on each access.
1 parent fb91fea commit 68bf538

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

smithy-model/src/main/java/software/amazon/smithy/model/traits/TimestampFormatTrait.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ public final class TimestampFormatTrait extends StringTrait {
1616
public static final String HTTP_DATE = "http-date";
1717
public static final ShapeId ID = ShapeId.from("smithy.api#timestampFormat");
1818

19+
private final Format format;
20+
1921
public TimestampFormatTrait(String value, SourceLocation sourceLocation) {
2022
super(ID, value, sourceLocation);
23+
this.format = Format.fromString(getValue());
2124
}
2225

2326
public TimestampFormatTrait(String value) {
@@ -30,7 +33,7 @@ public TimestampFormatTrait(String value) {
3033
* @return Returns the {@code Format} enum.
3134
*/
3235
public Format getFormat() {
33-
return Format.fromString(getValue());
36+
return format;
3437
}
3538

3639
public static final class Provider extends StringTrait.Provider<TimestampFormatTrait> {
@@ -48,7 +51,7 @@ public enum Format {
4851
HTTP_DATE(TimestampFormatTrait.HTTP_DATE),
4952
UNKNOWN("unknown");
5053

51-
private String value;
54+
private final String value;
5255

5356
Format(String value) {
5457
this.value = value;

0 commit comments

Comments
 (0)