類别範本 單例模板

技術從未如此性感發表於2018-07-19

類别範本
#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

#if (${IMPORT_BLOCK} != "")${IMPORT_BLOCK}
#end
#parse("File Header.java")
public  #if (${ABSTRACT} == "TRUE")abstract #end #if (${FINAL} == "TRUE")final #end class ${NAME} #if (${SUPERCLASS} != "")extends ${SUPERCLASS} #end #if (${INTERFACES} != "")implements ${INTERFACES} #end {
    private static final String TAG = ${NAME}.class.getSimpleName();
}


單例類别範本
#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

#if (${IMPORT_BLOCK} != "")${IMPORT_BLOCK}
#end
#parse("File Header.java")
public class ${NAME} #if (${SUPERCLASS} != "")extends ${SUPERCLASS} #end #if (${INTERFACES} != "")implements ${INTERFACES} #end {
    private static final String TAG = ${NAME}.class.getSimpleName();

    #if (${VISIBILITY} == "PUBLIC")public #end static ${NAME} getInstance() {
        return ${NAME}Holder.instance;
    }

    private ${NAME}() {
    }

    private static class ${NAME}Holder{
        public static ${NAME} instance = new ${NAME}();
    }
}
 

相關文章