- remove line with "package";
package; - change lines with "import"
import(delete the importimportkeyword, whitespaces, semicolon at the end) and add stripped packages with the Factory'sFactory's method addImport(line)addImport(line); - change "Preloadable"
Preloadableto "Generated"Generated - copy other lines without changes with the SourceWriter's
SourceWriter's method sw.println(line)sw.println(line)
The one more notice is that I can't use SourceWriterSourceWriter method sw.println(line)sw.println(line) before Factrory factory.addImport(line)Factrory factory.addImport(line);
My most worries are about calling line.contains("pattern")line.contains("pattern") in whilewhile-loooploop. As I know "pattern""pattern" will be compiled to Java regex Pattern.classPattern.class. I'm aware it's not good to compile the same PatternPattern over and over till the loop ends, but don't know how to do this better.
Also I doubt about this line (to strip "import"import lines)
line = line.substring(index + 6, line.lastIndexOf(";")).trim();
line = line.substring(index + 6, line.lastIndexOf(";")).trim();