Quantcast
Viewing latest article 1
Browse Latest Browse All 12

Java coded templates ( or code snippets )

Image may be NSFW.
Clik here to view.
Date Created: 
Mon, 2017-05-22 16:19
Date Updated: 
Fri, 2021-01-15 10:10
Florian Ingerl

This is an Eclipse plugin that allows the user to write code templates (or code snippets) for the Java editor where some template variables are computed from other template variables.

You can manage your Java-coded templates via the menu Window -> Preferences -> Java -> Editor -> Java-coded templates. Hit the New-button to start coding a new template.

E.g. the following would be code for a template for a private field with a getter-method

private ${type} ${field_name};
public ${type} ${getter: (String type, String field_name) ->
{
String s = Character.toUpperCase( field_name.charAt(0) ) + field_name.substring(1);
if(type.equals("boolean") )
return "is" + s;
else
return "get" + s;

}
}(){
return ${field_name};
}

After having successfully written your template, just type the first letters of the template's name into a Java editor and invoke content assist via Ctrl + Space.


Viewing latest article 1
Browse Latest Browse All 12

Trending Articles