@@ -22,8 +22,10 @@ customizations are supported:
2222- [ Change class modifier] ( #change-class-modifier )
2323- [ Change method modifier] ( #change-method-modifier )
2424- [ Change method return type] ( #change-method-return-type )
25+ - [ Change class super type] ( #change-class-super-type )
2526- [ Add an annotation to a class] ( #add-an-annotation-to-a-class )
2627- [ Add an annotation to a method] ( #add-an-annotation-to-a-method )
28+ - [ Add a field default value] ( #add-a-field-default-value )
2729- [ Remove an annotation from a class] ( #remove-an-annotation-from-a-class )
2830- [ Refactor: Generate the getter and setter methods for a property] ( #refactor-generate-the-getter-and-setter-methods-for-a-property )
2931- [ Refactor: Rename an enum member name] ( #refactor-rename-an-enum-member-name )
@@ -149,6 +151,36 @@ public class Foo {
149151
150152The ` UUID ` class will be automatically imported.
151153
154+ ## Change class super type
155+
156+ A class ` Foo ` extends ` Bar `
157+ ``` java readme-sample-change-class-base-type-initial
158+ public class Bar {
159+ }
160+ public class Foo extends Bar {
161+ }
162+ ```
163+
164+ with customization
165+ ``` java readme-sample-change-class-base-type-customization
166+ @Override
167+ public void customize(LibraryCustomization customization, Logger logger) {
168+ customization. getClass(" com.azure.myservice.models" , " Foo" )
169+ .customizeAst(ast - > ast. getClassByName(" foo" ). ifPresent(clazz - > {
170+ String newTypeFullName = " com.azure.myservice.models.Bar1" ;
171+ ast. addImport(newTypeFullName);
172+ clazz. getExtendedTypes(). clear();
173+ clazz. addExtendedType(new ClassOrInterfaceType (null , " Bar1" ));
174+ }));
175+ }
176+ ```
177+
178+ will generate
179+ ``` java readme-sample-change-class-base-type-result
180+ public class Foo extends Bar1 {
181+ }
182+ ```
183+
152184## Add an annotation to a class
153185
154186A class ` Foo `
@@ -218,6 +250,40 @@ public class Foo {
218250
219251The ` Deprecated ` class will be automatically imported.
220252
253+ ## Add a field default value
254+
255+ A class ` Foo `
256+
257+ ``` java readme-sample-add-a-field-default-value-initial
258+ public class Foo {
259+ private String bar;
260+ }
261+ ```
262+
263+ with customization
264+
265+ ``` java readme-sample-add-a-field-default-value-customization
266+ @Override
267+ public void customize(LibraryCustomization customization, Logger logger) {
268+ customization. getClass(" com.azure.myservice.models" , " Foo" )
269+ .customizeAst(ast - > ast. getClassByName(" Foo" )
270+ .flatMap(clazz - > clazz. getFieldByName(" bar" ))
271+ .ifPresent(barField - >
272+ barField. getVariables(). forEach(var - > {
273+ if (var . getNameAsString(). equals(" bar" )) {
274+ var . setInitializer(" \" bar\" " );
275+ }
276+ })));
277+ }
278+ ```
279+
280+ will generate
281+ ``` java readme-sample-add-a-field-default-value-result
282+ public class Foo {
283+ private String bar = " bar" ;
284+ }
285+ ```
286+
221287## Remove an annotation from a class
222288
223289A class ` Foo `
0 commit comments