Skip to content

Commit 405aff0

Browse files
committed
Merge pull request honza#385 from 0hansen/master
Corrections and singleton pattern for java
2 parents 92575e1 + 106d004 commit 405aff0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

snippets/java.snippets

+16-4
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,28 @@ snippet v
9191
##
9292
## Declaration for ArrayList
9393
snippet d.al
94-
List<${1:Object}> ${2:list} = ArrayList<$1>;${0}
94+
List<${1:Object}> ${2:list} = new ArrayList<$1>();${0}
9595
## Declaration for HashMap
9696
snippet d.hm
97-
Map<${1:Object}, ${2:Object}> ${3:map} = HashMap<$1, $2>;${0}
97+
Map<${1:Object}, ${2:Object}> ${3:map} = new HashMap<$1, $2>();${0}
9898
## Declaration for HashSet
9999
snippet d.hs
100-
Set<${1:Object}> ${2:set} = HashSet<$1>;${0}
100+
Set<${1:Object}> ${2:set} = new HashSet<$1>();${0}
101101
## Declaration for Stack
102102
snippet d.st
103-
Stack<${1:Object}> ${2:stack} = Stack<$1>;${0}
103+
Stack<${1:Object}> ${2:stack} = new Stack<$1>();${0}
104+
##
105+
## Singleton Pattern
106+
snippet singlet
107+
private static class Holder {
108+
private static final ${1:`vim_snippets#Filename("$1")`} INSTANCE = new $1();
109+
}
110+
111+
private $1() { }
112+
113+
private static $1 getInstance() {
114+
return Holder.INSTANCE;
115+
}
104116
##
105117
## Enhancements to Methods, variables, classes, etc.
106118
snippet ab

0 commit comments

Comments
 (0)