Added snippets for Emacs

This commit is contained in:
Fabio Scotto di Santolo
2025-12-27 13:53:55 +01:00
parent f81fb6d3fe
commit 07dfd8687a
115 changed files with 814 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
#name : author
# --
@author <a href="mailto:torstein@skybert.net">Torstein Krause Johansen</a>$0

View File

@@ -0,0 +1,6 @@
#name : debug
# --
if (mLogger.isDebugEnabled()) {
mLogger.debug(String.format("${1:result}=%s", ${2:result}));
}
$0

View File

@@ -0,0 +1,31 @@
#name : dwmain
# --
package ${1:net.skybert.dw};
import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.configuration.SubstitutingSourceProvider;
import io.dropwizard.jetty.ConnectorFactory;
import io.dropwizard.jetty.HttpConnectorFactory;
import io.dropwizard.lifecycle.Managed;
import io.dropwizard.server.DefaultServerFactory;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
/**
* Main
*/
public class Main extends Application<${2:SkybertConf}> {
public static void main(final String[] args) throws Exception {
new Main().run(args);
}
@Override
public void run(
final $2 pConfiguration,
final Environment pEnvironment)
throws Exception {
$0
}
}

View File

@@ -0,0 +1,5 @@
#name : new method/function
# --
${1:public} ${2:void} ${3:update}(final ${4:String} ${5:pName}) {
$0
}

View File

@@ -0,0 +1,5 @@
#name : for (...; ...; ...) { ... }
# --
for (${1:Object} ${downcase-word 1} ; ${2:list}) {
$0
}

View File

@@ -0,0 +1,5 @@
#name : for loop with index
# --
for (int ${1:i} = 0; $1 < ${2:args.length}; $1${3:++}) {
$0
}

View File

@@ -0,0 +1,13 @@
#name : get/set/member variable
# --
private ${1:String} ${2:name};
public void set${2:$(capitalize text)}(final $1 p${2:$(capitalize text)}) {
$2 = p${2:$(capitalize text)};
}
public $1 get${2:$(capitalize text)}() {
return $2;
}
$0

View File

@@ -0,0 +1,6 @@
#name : if
# --
if (${1:result} ${2:!=} ${3:null}) {
$0
}

View File

@@ -0,0 +1,4 @@
#name : static import of isBlank
# --
import static org.apache.commons.lang.StringUtils.isBlank;
$0

View File

@@ -0,0 +1,21 @@
#name : junitwrapperfns
# --
private void assertTrue(final String pMessage, final boolean pConditition) {
Assertions.assertTrue(pConditition, pMessage);
}
private void assertFalse(final String pMessage, final boolean pConditition) {
Assertions.assertFalse(pConditition, pMessage);
}
private void assertNotNull(final String pMessage, final Object pActual) {
Assertions.assertNotNull(pActual, pMessage);
}
private void assertNull(final String pMessage, final Object pActual) {
Assertions.assertNull(pActual, pMessage);
}
private void assertEquals(final String pMessage, final Object pExpected, final Object pActual) {
Assertions.assertEquals(pExpected, pActual, pMessage);
}

View File

@@ -0,0 +1,5 @@
#name : main
# --
public static void main(String[] args) {
$0
}

View File

@@ -0,0 +1,3 @@
#name : np
# --
// NOPMD

View File

@@ -0,0 +1,3 @@
#name : get ObjectLoader
# --
$0ObjectLoader objectLoader = IOAPI.getAPI().getObjectLoader();

View File

@@ -0,0 +1,6 @@
#name : req
# --
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create($0))
.timeout(Duration.ofMillis(getResponseTimeout()))
.build();

View File

@@ -0,0 +1,3 @@
#name : res
# --
HttpResponse<String> response = mHttpClient.send(request, ofString());$0

View File

@@ -0,0 +1,3 @@
#name : sf
# --
String.format("%s", $0)

View File

@@ -0,0 +1,3 @@
#name : System.out.println
# --
System.out.println($0);

View File

@@ -0,0 +1,4 @@
@Test
void ${1:can}() throws Exception {
$0
}

View File

@@ -0,0 +1,12 @@
#name : try, catch & finally
# --
try {
$0
}
catch (${1:Exception} ${2:e}) {
mLogger.error($2);
}
finally {
}

View File

@@ -0,0 +1,8 @@
#name : try & catch
# --
try {
$0
}
catch (${1:Exception} ${2:e}) {
mLogger.error($2);
}