// Path: virtualapk-gradle-plugin/src/main/java/com/didi/virtualapk/utils/Log.java
// public final class Log {
// 
//     private Log() {
// 
//     }
// 
//     public static int i(String tag, String msg) {
//         System.out.println("[INFO][" + tag + "] " + msg);
//         return 0;
//     }
// 
//     public static int e(String tag, String msg) {
//         System.err.println("[ERROR][" + tag + "] " + msg);
//         return 0;
//     }
// }


import com.didi.virtualapk.utils.Log;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
import javax.tools.StandardLocation;
        return false;
    }
    
    private void readDataBinderMapper() {
        BufferedReader reader = null;
        BufferedWriter writer = null;
        try {
            reader = new BufferedReader(fileObject.openReader(false));
    
            String className = DATA_BINDER_MAPPER_CLASS_NAME + "_" + modulePackage.replace('.', '_');
            JavaFileObject javaFileObject = processingEnv.getFiler().createSourceFile(DATA_BINDER_MAPPER_PACKAGE + "." + className);
            writer = new BufferedWriter(javaFileObject.openWriter());
            writer.write("// Generated by VirtualApk gradle plugin.");
            writer.newLine();
            
            String line;
            while ((line = reader.readLine()) != null) {
                if (line.contains(DATA_BINDER_MAPPER_CLASS_NAME)) {
                    if (line.contains("class")) {
                        line = line.replace(DATA_BINDER_MAPPER_CLASS_NAME, className + " extends " + DATA_BINDER_MAPPER_CLASS_NAME);
    
                    } else {
                        line = line.replace(DATA_BINDER_MAPPER_CLASS_NAME, className);
                    }
                }
                
                writer.write(line);
                writer.newLine();
            }
            
// Path: virtualapk-gradle-plugin/src/main/java/com/didi/virtualapk/utils/Log.java
// public final class Log {
// 
//     private Log() {
// 
//     }
// 
//     public static int i(String tag, String msg) {
//         System.out.println("[INFO][" + tag + "] " + msg);
//         return 0;
//     }
// 
//     public static int e(String tag, String msg) {
//         System.err.println("[ERROR][" + tag + "] " + msg);
//         return 0;
//     }
// }


// Path: virtualapk-gradle-plugin/src/main/java/com/didi/virtualapk/databinding/annotationprocessor/ProcessDataBinding.java
import com.didi.virtualapk.utils.Log;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
import javax.tools.StandardLocation;

        return false;
    }
    
    private void readDataBinderMapper() {
        BufferedReader reader = null;
        BufferedWriter writer = null;
        try {
            reader = new BufferedReader(fileObject.openReader(false));
    
            String className = DATA_BINDER_MAPPER_CLASS_NAME + "_" + modulePackage.replace('.', '_');
            JavaFileObject javaFileObject = processingEnv.getFiler().createSourceFile(DATA_BINDER_MAPPER_PACKAGE + "." + className);
            writer = new BufferedWriter(javaFileObject.openWriter());
            writer.write("// Generated by VirtualApk gradle plugin.");
            writer.newLine();
            
            String line;
            while ((line = reader.readLine()) != null) {
                if (line.contains(DATA_BINDER_MAPPER_CLASS_NAME)) {
                    if (line.contains("class")) {
                        line = line.replace(DATA_BINDER_MAPPER_CLASS_NAME, className + " extends " + DATA_BINDER_MAPPER_CLASS_NAME);
    
                    } else {
                        line = line.replace(DATA_BINDER_MAPPER_CLASS_NAME, className);
                    }
                }
                
                writer.write(line);
                writer.newLine();
            }
            
            Log.i("ProcessDataBinding", "Generated java source file: " + DATA_BINDER_MAPPER_PACKAGE + "." + className);