Skip to content

Commit 34b2289

Browse files
kstichsrchase
authored andcommitted
Add accessors on document member visitors
These accessors are necessary to allow extending implementations to not need to store their own copies of this information in order to perform their own work.
1 parent 2aa0921 commit 34b2289

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberDeserVisitor.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@
6666
* TODO: Update this with a mechanism to handle String and Blob shapes with the @mediatype trait.
6767
*/
6868
public class DocumentMemberDeserVisitor implements ShapeVisitor<String> {
69-
private final Format defaultTimestampFormat;
7069
private final GenerationContext context;
7170
private final String dataSource;
71+
private final Format defaultTimestampFormat;
7272

7373
/**
7474
* Constructor.
@@ -89,16 +89,34 @@ public DocumentMemberDeserVisitor(
8989
this.defaultTimestampFormat = defaultTimestampFormat;
9090
}
9191

92+
/**
93+
* Gets the generation context.
94+
*
95+
* @return The generation context.
96+
*/
97+
protected final GenerationContext getContext() {
98+
return context;
99+
}
100+
92101
/**
93102
* Gets the in-code location of the data to provide an output of
94103
* ({@code output.foo}, {@code entry}, etc.).
95104
*
96105
* @return The data source.
97106
*/
98-
protected String getDataSource() {
107+
protected final String getDataSource() {
99108
return dataSource;
100109
}
101110

111+
/**
112+
* Gets the default timestamp format used in absence of a TimestampFormat trait.
113+
*
114+
* @return The default timestamp format.
115+
*/
116+
protected final Format getDefaultTimestampFormat() {
117+
return defaultTimestampFormat;
118+
}
119+
102120
@Override
103121
public String blobShape(BlobShape shape) {
104122
return "context.base64Decoder(" + dataSource + ")";

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberSerVisitor.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
* TODO: Update this with a mechanism to handle String and Blob shapes with the @mediatype trait.
6666
*/
6767
public class DocumentMemberSerVisitor implements ShapeVisitor<String> {
68-
private final Format defaultTimestampFormat;
6968
private final GenerationContext context;
7069
private final String dataSource;
70+
private final Format defaultTimestampFormat;
7171

7272
/**
7373
* Constructor.
@@ -88,16 +88,34 @@ public DocumentMemberSerVisitor(
8888
this.defaultTimestampFormat = defaultTimestampFormat;
8989
}
9090

91+
/**
92+
* Gets the generation context.
93+
*
94+
* @return The generation context.
95+
*/
96+
protected final GenerationContext getContext() {
97+
return context;
98+
}
99+
91100
/**
92101
* Gets the in-code location of the data to provide an input of
93102
* ({@code input.foo}, {@code entry}, etc.).
94103
*
95104
* @return The data source.
96105
*/
97-
protected String getDataSource() {
106+
protected final String getDataSource() {
98107
return dataSource;
99108
}
100109

110+
/**
111+
* Gets the default timestamp format used in absence of a TimestampFormat trait.
112+
*
113+
* @return The default timestamp format.
114+
*/
115+
protected final Format getDefaultTimestampFormat() {
116+
return defaultTimestampFormat;
117+
}
118+
101119
@Override
102120
public String blobShape(BlobShape shape) {
103121
return "context.base64Encoder(" + dataSource + ")";

0 commit comments

Comments
 (0)