1212import java .util .EnumSet ;
1313import java .util .List ;
1414import java .util .Set ;
15- import java .util .function .Function ;
1615
1716/**
1817 * Config wrappers.
1918 *
2019 * @author Cause Chung
2120 */
21+ @ Getter
2222public final class Config {
23- @ Getter
2423 private final SharedType anno ;
25- @ Getter
2624 private final String simpleName ;
27- @ Getter
2825 private final String qualifiedName ;
2926 private final Set <SharedType .ComponentType > includedComponentTypes ;
30- @ Getter
3127 private final boolean constantNamespaced ;
32- @ Getter
3328 private final Set <Props .Typescript .OptionalFieldFormat > typescriptOptionalFieldFormats ;
34- @ Getter
3529 private final Props .Typescript .EnumFormat typescriptEnumFormat ;
30+ private final Props .Typescript .FieldReadonlyType typescriptFieldReadonly ;
3631
3732 @ Retention (RetentionPolicy .RUNTIME )
3833 @interface AnnoContainer {
@@ -54,6 +49,7 @@ public Config(TypeElement typeElement, Context ctx) {
5449 constantNamespaced = evaluateOptionalBool (anno .constantNamespaced (), ctx .getProps ().isConstantNamespaced ());
5550 typescriptOptionalFieldFormats = parseTsOptionalFieldFormats (anno , ctx );
5651 typescriptEnumFormat = parseTsEnumFormat (anno , ctx );
52+ typescriptFieldReadonly = parseTsFieldReadonlyType (anno , ctx );
5753 }
5854
5955 public boolean includes (SharedType .ComponentType componentType ) {
@@ -95,4 +91,16 @@ private static Props.Typescript.EnumFormat parseTsEnumFormat(SharedType anno, Co
9591 }
9692 return ctx .getProps ().getTypescript ().getEnumFormat ();
9793 }
94+
95+ private static Props .Typescript .FieldReadonlyType parseTsFieldReadonlyType (SharedType anno , Context ctx ) {
96+ if (anno .typescriptFieldReadonlyType () != null && !anno .typescriptFieldReadonlyType ().isEmpty ()) {
97+ try {
98+ return Props .Typescript .FieldReadonlyType .fromString (anno .typescriptFieldReadonlyType ());
99+ } catch (IllegalArgumentException e ) {
100+ throw new SharedTypeException (String .format (
101+ "Invalid value for SharedType.typescriptFieldReadonlyType: '%s', only 'all', 'acyclic', 'none' is allowed." , anno .typescriptFieldReadonlyType ()), e );
102+ }
103+ }
104+ return ctx .getProps ().getTypescript ().getFieldReadonlyType ();
105+ }
98106}
0 commit comments