Created
March 14, 2012 02:20
-
-
Save daveshah/2033487 to your computer and use it in GitHub Desktop.
Example of Extension Methods on Strings in Xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import junit.framework.Assert | |
import org.junit.Test | |
class ExtensionMethodsTest { | |
@Test | |
def shouldBeNull() { | |
var String myTestString = null; | |
Assert::assertTrue(myTestString.isEmptyOrNull()); | |
} | |
@Test | |
def shouldBeEmpty() { | |
var String myTestString = ""; | |
Assert::assertTrue(myTestString.isEmptyOrNull()); | |
} | |
def isEmptyOrNull(String s) { | |
s == null || s.isEmpty() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment