Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Add JDT Templates that set Guava Preconditions
# @title Add JDT templates that set Guava Preconditions
# @description Sets templates that surround expressions with Preconditions.check{NotNull,Argument,State}. Warning: this can replace any previously defined template so use with care.
# @task_type LASTMOD
#
# Written by Robert Konigsberg, 02-20-2012.
# See http://blatherberg.wordpress.com/2012/02/20/inserting-guava-preconditions-in-eclipse
#
file_export_version=3.0
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="java" deleted\="false" description\="Surround expression with checkNotNull Precondition." enabled\="true" name\="checkNotNull (instance)">${\:import(com.google.common.base.Preconditions)}Preconditions.checkNotNull(${word_selection})</template><template autoinsert\="false" context\="java" deleted\="false" description\="Surround expression with checkNotNull Precondition (with static import)." enabled\="true" name\="checkNotNull (static)">${\:importStatic(com.google.common.base.Preconditions.checkNotNull)}checkNotNull(${word_selection})</template><template autoinsert\="false" context\="java" deleted\="false" description\="Surround boolean expression with checkState Precondition." enabled\="true" name\="checkState (instance)">${\:import(com.google.common.base.Preconditions)}Preconditions.checkState(${word_selection})</template><template autoinsert\="false" context\="java" deleted\="false" description\="Surround boolean expression with checkState Precondition (with static import)." enabled\="true" name\="checkState (static)">${\:importStatic(com.google.common.base.Preconditions.checkState)}checkState(${word_selection})</template><template autoinsert\="false" context\="java" deleted\="false" description\="Surround boolean expression with checkArgument Precondition." enabled\="true" name\="checkArgument (instance)">${\:import(com.google.common.base.Preconditions)}Preconditions.checkArgument(${word_selection})</template><template autoinsert\="false" context\="java" deleted\="false" description\="Surround boolean expression with checkArgument Precondition (with static import)." enabled\="true" name\="checkArgument (static)">${\:importStatic(com.google.common.base.Preconditions.checkArgument)}checkArgument(${word_selection})</template></templates>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment