|
25 | 25 | * |
26 | 26 | * <p> |
27 | 27 | * <b>Configurations:</b><br> |
28 | | - * Properties on class level (via this annotation) will take precedence over global properties. |
29 | | - * Properties that only apply to global level will not be present on class level. |
| 28 | + * Global properties can be defined in a client provided property file or system properties. |
| 29 | + * By default, SharedType will look for file name "sharedtype.properties" on cmd current path. |
| 30 | + * The property file path can be changed via compiler option "sharedtype.propsFile", see web for details. |
| 31 | + * System properties will override property file values. |
| 32 | + * Configs on class level (via this annotation) will take precedence over global properties. |
30 | 33 | * </p> |
31 | 34 | * |
32 | 35 | * <p> |
|
97 | 100 | * By default, types that are recognized as date and time are emitted as strings, date/time types are configured via global properties. |
98 | 101 | * The emitted target type can be configured via global properties or via this annotation. |
99 | 102 | * Target type can be any type literal, but SharedType will not verify its validity in emitted code. |
| 103 | + * </p><br> |
| 104 | + * |
| 105 | + * <p> |
| 106 | + * <b>Type literal mappings:</b><br> |
| 107 | + * You dan define any 1-to-1 type mappings via global properties. This is useful when e.g. a 3rd party type is referenced. |
| 108 | + * Note, SharedType will still try to resolve the type and emit it with the mapped name. |
| 109 | + * If you don't want SharedType to auto-resolve and emit it, mark it as ignored via {@link SharedType.Ignore} or global properties. |
| 110 | + * <br> |
| 111 | + * Type mapped this way will take the highest precedence. |
| 112 | + * E.g. a date type is configured to be emitted as string, you can override the particular mapping to emit a {@code Date}. |
| 113 | + * Type mapping will override name configured in {@link SharedType#name()}. |
100 | 114 | * </p> |
101 | 115 | * |
102 | 116 | * <br> |
|
115 | 129 | * This may be used to help avoid conflicting names in target code. |
116 | 130 | * </p> |
117 | 131 | * <br> |
118 | | - * <p> |
119 | | - * How conflicting names are resolved: |
120 | | - * <ul> |
121 | | - * <li>Typescript: simple name of a class is used as type name. Duplicate names are not allowed.</li> |
122 | | - * </ul> |
| 132 | + * This is similar to but different from type mappings configured via global properties, |
| 133 | + * which maps any Java type to a target type. When both are defined, this will be overridden by type mappings. |
| 134 | + * See {@link SharedType} for details. |
123 | 135 | */ |
124 | 136 | String name() default ""; |
125 | 137 |
|
|
163 | 175 |
|
164 | 176 | /** |
165 | 177 | * Type literal to be emitted for date/time types. How a java type is considered a date/time type is defined by global properties. |
| 178 | + * |
166 | 179 | * @return any literal, e.g. "String", "chrono::DateTime". When empty, fallback to global default. |
167 | 180 | */ |
168 | 181 | String rustTargetDatetimeTypeLiteral() default ""; |
169 | 182 |
|
170 | 183 | /** |
171 | 184 | * How to render optional fields in Typescript. |
| 185 | + * |
172 | 186 | * @return combination of "?", "null", "undefined", the latter 2 are rendered as union types. If empty, fallback to global default. |
173 | 187 | */ |
174 | 188 | String[] typescriptOptionalFieldFormat() default {}; |
175 | 189 |
|
176 | 190 | /** |
177 | 191 | * Format of enum in Typescript. |
| 192 | + * |
178 | 193 | * @return one of "const_enum" (const enum), "enum" (enum), or "union" (union types). If empty, fallback to global default. |
179 | 194 | */ |
180 | 195 | String typescriptEnumFormat() default ""; |
181 | 196 |
|
182 | 197 | /** |
183 | 198 | * Whether to mark generated type fields as readonly. Default fallback to global properties. |
| 199 | + * |
184 | 200 | * @return value can be one of: |
185 | | - * "all" - all fields are readonly |
186 | | - * "acyclic" - only fields of not cyclic-referenced types are readonly |
187 | | - * "none" - no fields are readonly |
| 201 | + * "all" - all fields are readonly |
| 202 | + * "acyclic" - only fields of not cyclic-referenced types are readonly |
| 203 | + * "none" - no fields are readonly |
188 | 204 | */ |
189 | 205 | String typescriptFieldReadonlyType() default ""; |
190 | 206 |
|
191 | 207 | /** |
192 | 208 | * Type literal to be emitted for date/time types. How a java type is considered a date/time type is defined by global properties. |
| 209 | + * |
193 | 210 | * @return any literal, e.g. "string", "Date". When empty, fallback to global default. |
194 | 211 | */ |
195 | 212 | String typescriptTargetDatetimeTypeLiteral() default ""; |
|
207 | 224 | /** |
208 | 225 | * Exclude fields, record components, accessors in a type, or a dependency type, e.g. a supertype. |
209 | 226 | * <p> |
210 | | - * <b>When placed on a type:</b> a subtype of this type will not extend this type in target code. |
211 | | - * But if this type is referenced directly as type of field or return type of accessor, a compilation error will be reported, |
212 | | - * unless the field or accessor is also ignored. |
| 227 | + * <b>When placed on a type:</b><br> |
| 228 | + * This type will not be emitted. |
| 229 | + * If this type has a subtype that is going to be emitted, the subtype will not extend this type and its members in target code. |
| 230 | + * But if this type is referenced directly as type of field or return type of accessor, and "safe-type-resolution" is enabled, |
| 231 | + * a compilation error will be reported, unless the field or accessor is also ignored. |
213 | 232 | * </p> |
214 | 233 | */ |
215 | 234 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) |
@@ -295,7 +314,9 @@ enum ComponentType { |
295 | 314 | enum OptionalBool { |
296 | 315 | TRUE, |
297 | 316 | FALSE, |
298 | | - /** Fallback to global default. */ |
| 317 | + /** |
| 318 | + * Fallback to global default. |
| 319 | + */ |
299 | 320 | DEFAULT, |
300 | 321 | } |
301 | 322 | } |
0 commit comments