{"id":16445744,"url":"https://github.com/mnuessler/eclipse-templates","last_synced_at":"2025-02-26T10:14:28.721Z","repository":{"id":3932029,"uuid":"5022520","full_name":"mnuessler/eclipse-templates","owner":"mnuessler","description":"A collection of code templates I created for the editor of the Eclipse IDE.","archived":false,"fork":false,"pushed_at":"2012-07-25T16:35:16.000Z","size":124,"stargazers_count":25,"open_issues_count":0,"forks_count":20,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-24T02:14:16.642Z","etag":null,"topics":["eclipse-ide","eclipse-templates"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mnuessler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-13T17:20:48.000Z","updated_at":"2024-12-26T23:18:53.000Z","dependencies_parsed_at":"2022-08-29T02:31:10.775Z","dependency_job_id":null,"html_url":"https://github.com/mnuessler/eclipse-templates","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnuessler%2Feclipse-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnuessler%2Feclipse-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnuessler%2Feclipse-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnuessler%2Feclipse-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mnuessler","download_url":"https://codeload.github.com/mnuessler/eclipse-templates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240831380,"owners_count":19864718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eclipse-ide","eclipse-templates"],"created_at":"2024-10-11T09:45:15.554Z","updated_at":"2025-02-26T10:14:28.685Z","avatar_url":"https://github.com/mnuessler.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eclipse Templates #\n\nEclipse comes with a bunch of code templates that can save you a lot\nof typing. Most notably the templates `sysout` (expands to\n`System.out.println()`) and `for` / `foreach` to easily iterate over a\ncollection or an array.\n\nIt is also easy to add custom templates. This repository contains some\nof the templates I created and which might be useful for others too.\n\n## Java Templates ##\n\n### Category: Logging ###\n\n#### Create SLF4J Logger ####\n\n*Name:* `logger`\n\n*Description:* Creates an [SLF4J][slf4j] logger instance with the name of the enclosing class.\n\n*Example:*\n\nThis code\n\n```java\npublic class Foo {\n\tlogger\u003cCTRL-SPC\u003e\n}\n```\n\nexpands to\n\n```java\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\npublic class Foo {\n\tprivate static final Logger LOG = LoggerFactory.getLogger(Foo.class);\n}\n```\n\n#### Log message ####\n\n*Name:* `log`\n\n*Description:* Creates a log statement. Lets you select the level from a\nlist of choices.\n\n*Example:*\n\nThis code\n\n```java\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\npublic class Foo {\n\tprivate static final Logger LOG = LoggerFactory.getLogger(Foo.class);\n\n\tpublic void bar() {\n\t\tlog\u003cCTRL-SPC\u003e\n\t}\n}\n```\n\nexpands to\n\n```java\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\npublic class Foo {\n\tprivate static final Logger LOG = LoggerFactory.getLogger(Foo.class);\n\n\tpublic void bar() {\n\t\tLOG.debug(\"\");\n\t}\n}\n```\n\n#### Log debug message ####\n\n*Name:* `logd`\n\n*Description:* Same as `log` but with fixed DEBUG level.\n\n#### Log info message ####\n\n*Name:* `logi`\n\n*Description:* Same as `log` but with fixed INFO level.\n\n#### Log warning message ####\n\n*Name:* `logw`\n\n*Description:* Same as `log` but with fixed WARN level.\n\n#### Log error message ####\n\n*Name:* `loge`\n\n*Description:* Same as `log` but with fixed ERROR level.\n\n### Category: JUnit Tests ###\n\n#### Test method ####\n\n*Name:* `test`\n\n*Description:* Creates a JUnit test method body annotated with `@Test`\nand prompts you for the test method name.\n\nThis templates is an enhancement of the standard template `Test`\nshipped with Eclipse. Additional to the standard template, the\nfollowing static imports are added:\n\n* `org.junit.Assert.*`\n* `org.hamcrest.Matchers.*`\n* `org.easymock.EasyMock.*`\n\n*Example:*\n\nThis code\n\n```java\npublic class FooTest {\n}\n```\n\nexpands to\n\n```java\nimport static org.junit.Assert.*;\nimport static org.hamcrest.Matchers.*;\nimport static org.easymock.Easymock.*;\n\npublic class FooTest {\n\n\t@Test\n\tpublic void testX() throws Exception {\n\t}\n\n}\n```\n\n#### Test Assertion ####\n\n*Name:* `assert`\n\n*Description:* Creates a JUnit assertion body. Adds useful static imports.\n\n*Example:*\n\nThis code\n\n```java\npublic class FooTest {\n\n\t@Test\n\tpublic void testBar() throws Exception {\n\t\tassert\u003cCTRL-SPC\u003e\n\t}\n\n}\n```\n\nexpands to\n\n```java\nimport static org.junit.Assert.assertThat;\nimport static org.hamcrest.Matchers.*;\n\npublic class FooTest {\n\n\t@Test\n\tpublic void testBar() throws Exception {\n\t\tassertThat( , Matchers. );\n\t}\n\n}\n```\n\n#### Test Setup ####\n\n*Name:* `before`\n\n*Description:* Creates a test setup method body.\n\n*Example:*\n\nThis code\n\n```java\npublic class FooTest {\n\nbefore\u003cCTRL-SPC\u003e\n\n}\n```\n\nexpands to\n\n```java\nimport org.junit.Before;\n\npublic class FooTest {\n\n\t@Before\n\tpublic void setUp() throws Exception {\n\n\t}\n\n}\n```\n\n#### Test Teardown ####\n\n*Name:* `after`\n\n*Description:* Creates a test teardown method body.\n\n*Example:*\n\nThis code\n\n```java\npublic class FooTest {\n\nafter\u003cCTRL-SPC\u003e\n\n}\n```\n\nexpands to\n\n```java\nimport org.junit.After;\n\npublic class FooTest {\n\n\t@After\n\tpublic void tearDown() throws Exception {\n\n\t}\n\n}\n```\n\n#### Test Setup Before Class ####\n\n*Name:* `beforeclass`\n\n*Description:* Creates a test setup-before-class method body.\n\n*Example:*\n\nThis code\n\n```java\npublic class FooTest {\n\nbeforeclass\u003cCTRL-SPC\u003e\n\n}\n```\n\nexpands to\n\n```java\nimport org.junit.BeforeClass;\n\npublic class FooTest {\n\n\t@BeforeClass\n\tpublic void setUpBeforeClass() throws Exception {\n\n\t}\n\n}\n```\n\n#### Test Teardown After Class ####\n\n*Name:* `afterclass`\n\n*Description:* Creates a test teardown-after-class method body.\n\n*Example:*\n\nThis code\n\n```java\npublic class FooTest {\n\nafterclass\u003cCTRL-SPC\u003e\n\n}\n```\n\nexpands to\n\n```java\nimport org.junit.AfterClass;\n\npublic class FooTest {\n\n\t@AfterClass\n\tpublic void tearDownAfterClass() throws Exception {\n\n\t}\n\n}\n```\n\n### Category: Misc ###\n\n#### Iterate over Map ####\n\n*Name:* `formap`\n\n*Description:* Iterates over the entries of a `java.util.Map` with a\nforeach loop.\n\n*Example:*\n\nThis code\n\n```java\nMap\u003cString, String\u003e myMap = new HashMap\u003cString, String\u003e();\n\nformap\u003cCTRL-SPC\u003e\u003e\n```\n\nexpands to\n\n```java\nMap\u003cString, String\u003e myMap = new HashMap\u003cString, String\u003e();\n\nfor (Map.Entry\u003c , \u003e entry : myMap.entrySet()) {\n\n}\n```\n\n#### Check for null ####\n\n*Name:* `ifnull`\n\n*Description:* Creates a block to execute when a local variable is\nnull.\n\n*Example:*\n\nThis code\n\n```java\nInteger i = null;\n\nifnull\u003cCTRL-SPC\u003e\u003e\n```\n\nexpands to\n\n```java\nInteger i = null;\n\nif (i == null) {\n\n}\n```\n\n#### Check for not-null ####\n\n*Name:* `ifnotnull`\n\n*Description:* Creates a block to execute when a local variable is\nnot null.\n\n*Example:*\n\nThis code\n\n```java\nInteger i = null;\n\nifnotnull\u003cCTRL-SPC\u003e\u003e\n```\n\nexpands to\n\n```java\nInteger i = null;\n\nif (i != null) {\n\n}\n```\n\n#### Equals- / HashCode- / ToStringBuilder ####\n\n*Name:* `builder`\n\n*Description:* Creates `equals()`, `hashCode()` and `toString()` methods\nwhich make use of the builder classes from [commons-lang][lang]. When\ntyping field names (up to 3), those are inserted accordingly in each\nof the 3 methods.\n\n*Example:*\n\nThis code\n\n```java\npublic class Foo {\n\nbuilder\u003cCTRL-SPC\u003e\n\n}\n```\n\nexpands to\n\n```java\nimport org.apache.commons.lang3.builder.EqualsBuilder;\nimport org.apache.commons.lang3.builder.HashCodeBuilder;\nimport org.apache.commons.lang3.builder.ToStringBuilder;\n\npublic class Foo {\n\n\t@Override\n\tpublic boolean equals(Object obj) {\n\t\tif (obj == null) { return false; }\n\t\tif (obj == this) { return true; }\n\t\tif (obj.getClass() != getClass()) { return false; }\n\t\tFoo rhs = (Foo) obj;\n\t\treturn new EqualsBuilder()\n\t\t.appendSuper(super.equals(obj))\n\t\t.append(this.field1, rhs.field1)\n\t\t.append(this.field2, rhs.field2)\n\t\t.append(this.field3, rhs.field3)\n\t\t.isEquals();\n\t}\n\n\t@Override\n\tpublic int hashCode() {\n\t\treturn new HashCodeBuilder(17, 37)\n\t\t.append(field1)\n\t\t.append(field2)\n\t\t.append(field3)\n\t\t.toHashCode();\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)\n\t\t.append(\"field1\", field1)\n\t\t.append(\"field2\", field2)\n\t\t.append(\"field3\", field3)\n\t\t.toString();\n\t}\n\n}\n```\n\n#### Equals- / HashCode- / ToStringBuilder with Reflection ####\n\n*Name:* `builder equals hashcode reflection`\n\n*Description:* Creates `equals()`, `hashCode()` and `toString()` methods\nwhich make use of the builder classes from [commons-lang][lang] using\ntheir reflection-based methods.\n\n*Example:*\n\nThis code\n\n```java\npublic class Foo {\n\nbuilder\u003cCTRL-SPC\u003e\n\n}\n```\n\nexpands to\n\n```java\nimport org.apache.commons.lang3.builder.EqualsBuilder;\nimport org.apache.commons.lang3.builder.HashCodeBuilder;\nimport org.apache.commons.lang3.builder.ToStringBuilder;\n\npublic class Foo {\n\n\t@Override\n\tpublic boolean equals(Object obj) {\n\t\treturn EqualsBuilder.reflectionEquals(this, obj);\n\t}\n\n\t@Override\n\tpublic int hashCode() {\n\t\treturn HashCodeBuilder.reflectionHashCode(17, 37, this);\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);\n\t}\n\n}\n```\n\n## Installation ##\n\n\n\n[slf4j]: http://www.slf4j.org/\n[lang]: http://commons.apache.org/lang/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnuessler%2Feclipse-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnuessler%2Feclipse-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnuessler%2Feclipse-templates/lists"}