1
0
Fork 0
mirror of synced 2024-11-23 01:05:34 -05:00
ultimate-vim/sources_non_forked/vim-snippets/snippets/java.snippets

288 lines
5.2 KiB
Text
Raw Normal View History

2012-08-16 23:41:25 -04:00
## Access Modifiers
snippet po
2014-07-02 07:18:18 -04:00
protected ${0}
2012-08-16 23:41:25 -04:00
snippet pu
2014-07-02 07:18:18 -04:00
public ${0}
2012-08-16 23:41:25 -04:00
snippet pr
2014-07-02 07:18:18 -04:00
private ${0}
2012-08-16 23:41:25 -04:00
##
## Annotations
snippet before
@Before
static void ${1:intercept}(${2:args}) { ${0} }
2012-08-16 23:41:25 -04:00
snippet mm
@ManyToMany
${0}
2012-08-16 23:41:25 -04:00
snippet mo
@ManyToOne
${0}
2012-08-16 23:41:25 -04:00
snippet om
@OneToMany${1:(cascade=CascadeType.ALL)}
${0}
2012-08-16 23:41:25 -04:00
snippet oo
@OneToOne
${1}
##
## Basic Java packages and import
snippet im
2014-07-02 07:18:18 -04:00
import ${0}
2012-08-16 23:41:25 -04:00
snippet j.b
java.beans.
snippet j.i
java.io.
snippet j.m
java.math.
snippet j.n
java.net.
snippet j.u
java.util.
##
## Class
snippet cl
2014-07-02 07:18:18 -04:00
class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0}
2014-09-27 11:32:18 -04:00
snippet pcl
public class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0}
2012-08-16 23:41:25 -04:00
snippet in
2014-07-02 07:18:18 -04:00
interface ${1:`vim_snippets#Filename("$1", "untitled")`} ${2:extends Parent}
2012-08-16 23:41:25 -04:00
snippet tc
2014-07-02 07:18:18 -04:00
public class ${1:`vim_snippets#Filename("$1")`} extends ${0:TestCase}
2012-08-16 23:41:25 -04:00
##
## Class Enhancements
snippet ext
2014-07-02 07:18:18 -04:00
extends ${0}
2012-08-16 23:41:25 -04:00
snippet imp
2014-07-02 07:18:18 -04:00
implements ${0}
2012-08-16 23:41:25 -04:00
##
## Comments
snippet /*
/*
* ${0}
2012-08-16 23:41:25 -04:00
*/
##
## Constants
snippet co
static public final ${1:String} ${2:var} = ${3};
2012-08-16 23:41:25 -04:00
snippet cos
static public final String ${1:var} = "${2}";
2012-08-16 23:41:25 -04:00
##
## Control Statements
snippet case
case ${1}:
${0}
2012-08-16 23:41:25 -04:00
snippet def
default:
${0}
2012-08-16 23:41:25 -04:00
snippet el
else
2013-07-17 19:06:05 -04:00
snippet eif
else if (${1}) ${0}
2012-08-16 23:41:25 -04:00
snippet if
if (${1}) ${0}
2012-08-16 23:41:25 -04:00
snippet sw
switch (${1}) {
${0}
2012-08-16 23:41:25 -04:00
}
##
## Create a Method
snippet m
${1:void} ${2:method}(${3}) ${4:throws }
2012-08-16 23:41:25 -04:00
##
## Create a Variable
snippet v
${1:String} ${2:var}${3: = null}${4};
2012-08-16 23:41:25 -04:00
##
2014-07-02 07:18:18 -04:00
## Declaration for ArrayList
snippet d.al
List<${1:Object}> ${2:list} = new ArrayList<$1>();${0}
## Declaration for HashMap
snippet d.hm
Map<${1:Object}, ${2:Object}> ${3:map} = new HashMap<$1, $2>();${0}
## Declaration for HashSet
snippet d.hs
Set<${1:Object}> ${2:set} = new HashSet<$1>();${0}
## Declaration for Stack
snippet d.st
Stack<${1:Object}> ${2:stack} = new Stack<$1>();${0}
##
## Singleton Pattern
snippet singlet
private static class Holder {
private static final ${1:`vim_snippets#Filename("$1")`} INSTANCE = new $1();
}
private $1() { }
public static $1 getInstance() {
return Holder.INSTANCE;
}
##
2012-08-16 23:41:25 -04:00
## Enhancements to Methods, variables, classes, etc.
snippet ab
2014-07-02 07:18:18 -04:00
abstract ${0}
2012-08-16 23:41:25 -04:00
snippet fi
2014-07-02 07:18:18 -04:00
final ${0}
2012-08-16 23:41:25 -04:00
snippet st
2014-07-02 07:18:18 -04:00
static ${0}
2012-08-16 23:41:25 -04:00
snippet sy
2014-07-02 07:18:18 -04:00
synchronized ${0}
2012-08-16 23:41:25 -04:00
##
## Error Methods
snippet err
System.err.print("${0:Message}");
2012-08-16 23:41:25 -04:00
snippet errf
System.err.printf("${1:Message}", ${0:exception});
2012-08-16 23:41:25 -04:00
snippet errln
System.err.println("${0:Message}");
2012-08-16 23:41:25 -04:00
##
## Exception Handling
snippet as
assert ${1:test} : "${2:Failure message}";
2014-07-02 07:18:18 -04:00
snippet ae
assertEquals("${1:Failure message}", ${2:expected}, ${3:actual});
snippet aae
assertArrayEquals("${1:Failure message}", ${2:expecteds}, ${3:actuals});
snippet af
assertFalse("${1:Failure message}", ${2:condition});
snippet at
assertTrue("${1:Failure message}", ${2:condition});
snippet an
assertNull("${1:Failure message}", ${2:object});
snippet ann
assertNotNull("${1:Failure message}", ${2:object});
snippet ass
assertSame("${1:Failure message}", ${2:expected}, ${3:actual});
snippet asns
assertNotSame("${1:Failure message}", ${2:expected}, ${3:actual});
snippet fa
fail("${1:Failure message}");
2012-08-16 23:41:25 -04:00
snippet ca
catch(${1:Exception} ${2:e}) ${0}
2012-08-16 23:41:25 -04:00
snippet thr
2014-07-02 07:18:18 -04:00
throw ${0}
2012-08-16 23:41:25 -04:00
snippet ths
2014-07-02 07:18:18 -04:00
throws ${0}
2012-08-16 23:41:25 -04:00
snippet try
try {
${0}
2012-08-16 23:41:25 -04:00
} catch(${1:Exception} ${2:e}) {
}
snippet tryf
try {
${0}
2012-08-16 23:41:25 -04:00
} catch(${1:Exception} ${2:e}) {
} finally {
}
##
## Find Methods
snippet findall
List<${1:listName}> ${2:items} = ${1}.findAll();
2012-08-16 23:41:25 -04:00
snippet findbyid
${1:var} ${2:item} = ${1}.findById(${3});
2012-08-16 23:41:25 -04:00
##
## Javadocs
snippet /**
/**
* ${0}
2012-08-16 23:41:25 -04:00
*/
snippet @au
@author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5 | cut -d \",\" -f1")`
2012-08-16 23:41:25 -04:00
snippet @br
@brief ${0:Description}
2012-08-16 23:41:25 -04:00
snippet @fi
2014-07-02 07:18:18 -04:00
@file ${0:`vim_snippets#Filename("$1")`}.java
2012-08-16 23:41:25 -04:00
snippet @pa
@param ${0:param}
2012-08-16 23:41:25 -04:00
snippet @re
@return ${0:param}
2012-08-16 23:41:25 -04:00
##
## Logger Methods
snippet debug
Logger.debug(${1:param});
2012-08-16 23:41:25 -04:00
snippet error
Logger.error(${1:param});
2012-08-16 23:41:25 -04:00
snippet info
Logger.info(${1:param});
2012-08-16 23:41:25 -04:00
snippet warn
Logger.warn(${1:param});
2012-08-16 23:41:25 -04:00
##
## Loops
snippet enfor
for (${1} : ${2}) ${0}
2012-08-16 23:41:25 -04:00
snippet for
for (${1}; ${2}; ${3}) ${0}
2012-08-16 23:41:25 -04:00
snippet wh
while (${1}) ${0}
2012-08-16 23:41:25 -04:00
##
## Main method
snippet main
public static void main (String[] args) {
${0}
2012-08-16 23:41:25 -04:00
}
##
## Print Methods
snippet print
System.out.print("${0:Message}");
2012-08-16 23:41:25 -04:00
snippet printf
System.out.printf("${1:Message}", ${0:args});
2012-08-16 23:41:25 -04:00
snippet println
System.out.println(${0});
2015-07-13 06:22:46 -04:00
snippet printlna
System.out.println(Arrays.toString(${0}));
2012-08-16 23:41:25 -04:00
##
## Render Methods
snippet ren
render(${1:param});
2012-08-16 23:41:25 -04:00
snippet rena
renderArgs.put("${1}", ${2});
2012-08-16 23:41:25 -04:00
snippet renb
renderBinary(${1:param});
2012-08-16 23:41:25 -04:00
snippet renj
renderJSON(${1:param});
2012-08-16 23:41:25 -04:00
snippet renx
renderXml(${1:param});
2012-08-16 23:41:25 -04:00
##
## Setter and Getter Methods
snippet set
${1:public} void set${3:}(${2:String} ${0:}){
2012-08-16 23:41:25 -04:00
this.$4 = $4;
}
snippet get
${1:public} ${2:String} get${3:}(){
return this.${0:};
2012-08-16 23:41:25 -04:00
}
##
## Terminate Methods or Loops
snippet re
2014-07-02 07:18:18 -04:00
return ${0}
2012-08-16 23:41:25 -04:00
snippet br
break;
##
## Test Methods
snippet t
public void test${1:Name}() throws Exception {
${0}
2012-08-16 23:41:25 -04:00
}
snippet test
@Test
public void test${1:Name}() throws Exception {
${0}
2012-08-16 23:41:25 -04:00
}
##
## Utils
snippet Sc
Scanner
##
## Miscellaneous
snippet action
public static void ${1:index}(${2:args}) { ${0} }
2012-08-16 23:41:25 -04:00
snippet rnf
notFound(${1:param});
2012-08-16 23:41:25 -04:00
snippet rnfin
notFoundIfNull(${1:param});
2012-08-16 23:41:25 -04:00
snippet rr
redirect(${1:param});
2012-08-16 23:41:25 -04:00
snippet ru
unauthorized(${1:param});
2012-08-16 23:41:25 -04:00
snippet unless
(unless=${1:param});