The Code Protection is the integral part of the Codebricks Platform to work together with the Codegenerator.
It allows you to protect your custom code during the next generator run.
Currently we offer 3 Parts of Code Protection:
In all relevant methods of the generated code, the @OverwriteProtected
annotation can be found.
For example in a ValueObject:
1@OverwriteProtectionBody(false)2validate(value: string): void {3 if (!isType(value, String) || !value.length) {4 throw new ValidationError(`TaskTitleValueObject: ${value} is invalid`);5 }6}
By Setting the value of the Overwrite Protection to true, the body of the method is protected. That means it will stay after generating the code again.
Important: Only the body not the signature of the method is protected.
Note: For functions the Overwrite Protection is in a TypeDoc instead of an Annotation, but works in the same way.
In case additional Files and Folders are needed, you can create protected folders in any of the generated folders.
To make sure they stay in the code base after the next code generation run they have to be named custom
.
Any additional imports made inside the generated Classes will be preserved during the next code generation run by default.
Note: This works also if you add another named import to an existing import.
Additional Dependencies and scripts inside the package.json file inside the aggregate folder will be preserved.
Note: It is not possible to overwrite the dependency version or the scripts provided by the generator.