Skip to content

Commit ad254f8

Browse files
committed
Added singleton pattern
1 parent c24c99c commit ad254f8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

snippets/java.snippets

+12
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ snippet d.hs
102102
snippet d.st
103103
Stack<${1:Object}> ${2:stack} = new Stack<$1>();${0}
104104
##
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+
}
116+
##
105117
## Enhancements to Methods, variables, classes, etc.
106118
snippet ab
107119
abstract ${0}

0 commit comments

Comments
 (0)