Skip to content

Instantly share code, notes, and snippets.

@bsorrentino
Last active January 24, 2019 09:45
Show Gist options
  • Save bsorrentino/c736c2659f4a19dcdc48 to your computer and use it in GitHub Desktop.
Save bsorrentino/c736c2659f4a19dcdc48 to your computer and use it in GitHub Desktop.
Eclipse template (code snippet ) to check the argument and eventually throws IllegalArgumentException
  1. Download Gist
  2. Open Eclipse Preferences
  3. Go to Java/Editor/templates
  4. Click Import
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- JAVA8 SNIPPET -->
<templates>
<template autoinsert="true" context="java" deleted="false" description="check argument for null" enabled="true" name="notnull">
Objects.requireNonNull( ${name:var}, "${name} is null!" );
</template>
</templates>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- JAVA7 SNIPPET -->
<templates>
<template autoinsert="true" context="java" deleted="false" description="check argument for null" enabled="true" name="nullp">
if( ${name:var} == null ) throw new java.lang.IllegalArgumentException( "${name} is null!");
</template>
</templates>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment