[Minor] extended DBC with assertTrue and assertFalse

This commit is contained in:
Robert von Burg 2014-02-01 13:14:29 +01:00
parent 7ec21839d9
commit a4b459b11d
1 changed files with 24 additions and 0 deletions

View File

@ -26,6 +26,26 @@ import ch.eitchnet.utils.helper.StringHelper;
public enum DBC {
PRE {
@Override
public void assertTrue(String msg, boolean value) {
if (!value) {
String ex = "Expected true, but was false: {0}"; //$NON-NLS-1$
ex = MessageFormat.format(ex, msg);
throw new DbcException(ex);
}
}
@Override
public void assertFalse(String msg, boolean value) {
if (value) {
String ex = "Expected false, but was true: {0}"; //$NON-NLS-1$
ex = MessageFormat.format(ex, msg);
throw new DbcException(ex);
}
}
@Override
public void assertNotEmpty(String msg, String value) {
if (StringHelper.isEmpty(value)) {
String ex = "Illegal empty value: {0}"; //$NON-NLS-1$
@ -71,6 +91,10 @@ public enum DBC {
}
};
public abstract void assertTrue(String msg, boolean value);
public abstract void assertFalse(String msg, boolean value);
public abstract void assertNotEmpty(String msg, String value);
public abstract void assertNotNull(String msg, Object value);