IntelliJ Java Code Templates Configuration: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 23: Line 23:


     // Public ----------------------------------------------------------------------------------------------------------
     // Public ----------------------------------------------------------------------------------------------------------
   
#if (${NAME.endsWith("Test")})
#if (${NAME.endsWith("Test")})   // Tests -----------------------------------------------------------------------------------------------------------


    // Tests -----------------------------------------------------------------------------------------------------------
#end     
#end     
     // Package protected -----------------------------------------------------------------------------------------------
     // Package protected -----------------------------------------------------------------------------------------------



Revision as of 16:49, 20 December 2016

Internal

Overview

Class Template

Settings -> Editor -> Code & Style -> File and Code Templates -> Templates tab

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public class ${NAME} {

    // Constants -------------------------------------------------------------------------------------------------------

    // Static ----------------------------------------------------------------------------------------------------------

    // Attributes ------------------------------------------------------------------------------------------------------

    // Constructors ----------------------------------------------------------------------------------------------------

    // Public ----------------------------------------------------------------------------------------------------------
#if (${NAME.endsWith("Test")})

    // Tests -----------------------------------------------------------------------------------------------------------
#end    

    // Package protected -----------------------------------------------------------------------------------------------

    // Protected -------------------------------------------------------------------------------------------------------

    // Private ---------------------------------------------------------------------------------------------------------

    // Inner classes ---------------------------------------------------------------------------------------------------

}

Interface Template

Settings -> Editor -> Code & Style -> File and Code Templates -> Templates tab

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public interface ${NAME} {

    // Constants -------------------------------------------------------------------------------------------------------

    // Static ----------------------------------------------------------------------------------------------------------

    // Public ----------------------------------------------------------------------------------------------------------

}

Enum

Settings -> Editor -> Code & Style -> File and Code Templates -> Templates tab

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public enum ${NAME} {

    // Constants -------------------------------------------------------------------------------------------------------

    // Static ----------------------------------------------------------------------------------------------------------

    // Public ----------------------------------------------------------------------------------------------------------

}

File Header

Then go to the "Includes" tab and edit File Header:

/**
 * @author Ovidiu Feodorov <ovidiu@novaordis.com>
 * @since   ${DATE}
 */

Method Template

Preferences -> Editor -> File and Code Templates -> Code tab -> Implemented Method Body

Replace the content with

throw new NotYetImplementedException("${METHOD_NAME}() NOT YET IMPLEMENTED");