// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/constants/GuessClass.java
// public class GuessClass {
//     public static final String BASE_ROUTER_MAPPING = "com.wangjie.rapidrouter.core.RapidRouterMapping";
//     public static final String ROUTER_TARGET = "com.wangjie.rapidrouter.core.target.RouterTarget";
// 
// }
// 
// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/LogUtil.java
// public class LogUtil {
//     public static final boolean LOG_CONTROL = true;
//     public static final boolean LOG_FILE = false;
//     private static SimpleDateFormat LOGGER_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
// 
// 
//     public static void loggerE(Throwable throwable) {
//         if (!LOG_CONTROL && !LOG_FILE) {
//             return;
//         }
//         logger("[ERROR]" + transformStackTrace(throwable));
//     }
// 
//     public static void logger(String str) {
//         if (!LOG_CONTROL && !LOG_FILE) {
//             return;
//         }
//         String loggerDate = "...[" + LOGGER_DATE_FORMAT.format(new Date()) + "]";
//         String log = loggerDate + ": " + str;
//         if (LOG_CONTROL) {
//             GlobalEnvironment.getProcessingEnv().getMessager().printMessage(Diagnostic.Kind.NOTE, log);
//         }
//         if (LOG_FILE) {
//             writeToDisk(log);
//         }
//     }
// 
//     private static void writeToDisk(String log) {
//         try {
//             File logFile = new File("/Users/wangjie/Desktop/za/test/rapidorm/processor_http.txt");
//             if (!logFile.exists()) {
//                 logFile.getParentFile().mkdirs();
//                 logFile.createNewFile();
//             }
//             FileWriter fw = new FileWriter(logFile, true);
//             fw.write(log + "\n\n");
//             fw.close();
//         } catch (IOException e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public static StringBuilder transformStackTrace(StackTraceElement[] elements){
//         StringBuilder sb = new StringBuilder();
//         for(StackTraceElement element : elements){
//             sb.append(element.toString()).append("\r\n");
//         }
//         return sb;
//     }
//     public static String transformStackTrace(Throwable throwable){
//         if(null == throwable){
//             return "throwable is null";
//         }
//         StringBuilder sb = new StringBuilder(throwable.getMessage()).append("\n");
//         for(StackTraceElement element : throwable.getStackTrace()){
//             sb.append(element.toString()).append("\r\n");
//         }
//         return sb.toString();
//     }
// 
// }


import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import com.wangjie.rapidrouter.compiler.constants.GuessClass;
import com.wangjie.rapidrouter.compiler.util.LogUtil;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.lang.model.element.Modifier;
package com.wangjie.rapidrouter.compiler.objs;




/**
 * Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
 */
public class RouterEntry {
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:SSS");

    private List<UriEntry> uriEntries = new ArrayList<>();

    public List<UriEntry> getUriEntries() {
        return uriEntries;
    }

    public String routerMappingPackage;
    public String routerMappingClassName;

    public JavaFile brewJava() throws Throwable {
        if (null == routerMappingPackage || routerMappingPackage.length() == 0
                || null == routerMappingClassName || routerMappingClassName.length() == 0) {
            throw new RuntimeException("Have no Router Point Class  Annotated @RRPoint!");
        }

        TypeSpec.Builder result = TypeSpec.classBuilder(routerMappingClassName)
                .addModifiers(Modifier.PUBLIC)
                .superclass( // extends RapidRouterMapping
// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/constants/GuessClass.java
// public class GuessClass {
//     public static final String BASE_ROUTER_MAPPING = "com.wangjie.rapidrouter.core.RapidRouterMapping";
//     public static final String ROUTER_TARGET = "com.wangjie.rapidrouter.core.target.RouterTarget";
// 
// }
// 
// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/LogUtil.java
// public class LogUtil {
//     public static final boolean LOG_CONTROL = true;
//     public static final boolean LOG_FILE = false;
//     private static SimpleDateFormat LOGGER_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
// 
// 
//     public static void loggerE(Throwable throwable) {
//         if (!LOG_CONTROL && !LOG_FILE) {
//             return;
//         }
//         logger("[ERROR]" + transformStackTrace(throwable));
//     }
// 
//     public static void logger(String str) {
//         if (!LOG_CONTROL && !LOG_FILE) {
//             return;
//         }
//         String loggerDate = "...[" + LOGGER_DATE_FORMAT.format(new Date()) + "]";
//         String log = loggerDate + ": " + str;
//         if (LOG_CONTROL) {
//             GlobalEnvironment.getProcessingEnv().getMessager().printMessage(Diagnostic.Kind.NOTE, log);
//         }
//         if (LOG_FILE) {
//             writeToDisk(log);
//         }
//     }
// 
//     private static void writeToDisk(String log) {
//         try {
//             File logFile = new File("/Users/wangjie/Desktop/za/test/rapidorm/processor_http.txt");
//             if (!logFile.exists()) {
//                 logFile.getParentFile().mkdirs();
//                 logFile.createNewFile();
//             }
//             FileWriter fw = new FileWriter(logFile, true);
//             fw.write(log + "\n\n");
//             fw.close();
//         } catch (IOException e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public static StringBuilder transformStackTrace(StackTraceElement[] elements){
//         StringBuilder sb = new StringBuilder();
//         for(StackTraceElement element : elements){
//             sb.append(element.toString()).append("\r\n");
//         }
//         return sb;
//     }
//     public static String transformStackTrace(Throwable throwable){
//         if(null == throwable){
//             return "throwable is null";
//         }
//         StringBuilder sb = new StringBuilder(throwable.getMessage()).append("\n");
//         for(StackTraceElement element : throwable.getStackTrace()){
//             sb.append(element.toString()).append("\r\n");
//         }
//         return sb.toString();
//     }
// 
// }


// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/objs/RouterEntry.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import com.wangjie.rapidrouter.compiler.constants.GuessClass;
import com.wangjie.rapidrouter.compiler.util.LogUtil;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.lang.model.element.Modifier;

package com.wangjie.rapidrouter.compiler.objs;




/**
 * Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
 */
public class RouterEntry {
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:SSS");

    private List<UriEntry> uriEntries = new ArrayList<>();

    public List<UriEntry> getUriEntries() {
        return uriEntries;
    }

    public String routerMappingPackage;
    public String routerMappingClassName;

    public JavaFile brewJava() throws Throwable {
        if (null == routerMappingPackage || routerMappingPackage.length() == 0
                || null == routerMappingClassName || routerMappingClassName.length() == 0) {
            throw new RuntimeException("Have no Router Point Class  Annotated @RRPoint!");
        }

        TypeSpec.Builder result = TypeSpec.classBuilder(routerMappingClassName)
                .addModifiers(Modifier.PUBLIC)
                .superclass( // extends RapidRouterMapping
                        ClassName.bestGuess(GuessClass.BASE_ROUTER_MAPPING)