Find all *DTO classes, that have a (at least one) public field that is neither @ApiModelProperty, nor a @JsonIgnore
-
Open
Edit->Find->Search structurally -
Paste this into
Search templatefield:class $Class$ { @$FieldAnnotation$ public $type$ $field$; }
-
Click
Edit Variables:- for variable
Class: provide a regex for a class name:.+DTO - for variable
FieldAnnotation:- Text/regexp:
ApiModelProperty|JsonIgnore - Minimum count/Maximum count:
0/0
- Text/regexp:
- for variable
-
Choose
Scope(see here to define a scope) -
Click
Find -
If you're happy with results, click
Save Template...and provide a template name
-
Open
Edit->Find->Search structurally -
Paste this into
Search templatefield:class $className$ { public String $methodName$ (); }
-
Click
Edit Variables:- for variable
Class: provide a regex for a class name:.+DTO - for variable
methodName:- Text/regexp:
toString - Minimum count/Maximum count:
0/0
- Text/regexp:
- for variable
-
Choose
Scope(see here to define a scope) -
Click
Find -
If you're happy with results, click
Save Template...and provide a template name
-
Open
Edit->Find->Replace structurally -
Paste this into
Search templatefield:map.put("$field$","$a$");
-
Paste this into
Replace templatefield:map.put(FieldNames.$ENUMFIELD$, "$a$");
-
Click
Edit variables:-
for variable
ENUMFIELD, provideScript textas follows:import static com.google.common.base.CaseFormat.LOWER_CAMEL as LOWER_CAMEL import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE as UPPER_UNDERSCORE LOWER_CAMEL.to(UPPER_UNDERSCORE, field.getInnerText())
-
Click
OK
-
-
Click
Find -
Check validity of the results and replace when necessary
- Open
Edit->Find->Replace structurally - Paste this into
Searchfield:@$MethodAnnotation$ public void $MethodName$(@mockit.Injectable $ParameterType$ $Parameter$) { $statement$; }
- Choose file type:
Java - Class Member - Add filter for
MethodAnnotationvariable: Text=org.junit.jupiter.api.Test - Add Min=0 for
statementandParametervariables - Paste this into
Replacefield:(mind the indentation, otherwise it will be screwed!)@$MethodAnnotation$ void $MethodName$(@Injectable $ParameterType$ $Parameter$) { $statement$; }
- Select
Complete matchvalue forSearch target - Find
NB: for some reason, I could not make it "parameter annotation" agnostic... that's why @Injectable annotation is hardcoded in the template
- On a
Structural Searchwindow, click on ellipsis...button next toScopecombobox - Click
+button (Add Scope) or pressIns - In order to include only specific folder (with subfolders) in a search, put a construction into
Patternfield:file[modulename]:src/main/java/com/my/package//*
- Open
Edit->Find->Search structurally - Click
Existing templates - Select necessary template and click
OK