File and code templates

Answered

I am creating more classes and interfaces by the one template.

First case it that: when class name ended on "Service", I want to add annotation @Service to this class, when class name ended on "Bean", I want to add annotation @ManagedBean to this class. 

Second case is migrate my cursor in body of class after class or interface creating. (Note: $END$ not work correctly, IDEA suggests me complete field END in the code before class or interface created.

More formally, how can I compare end of the class name and how can I migrate my cursor to the body of the class? 

How can I solve this problems?

0
1 comment

Hello,

 

There is a known issue with "$END$": https://youtrack.jetbrains.com/issue/IDEA-159930. Please follow it for updates.

To enter annotations you may use this example:

 

#set ($classname = ${NAME})
#if($classname.toString().contains("Bean"))
@Bean
#else
@Service
#end
public class ${NAME} {
}

 

0

Please sign in to leave a comment.