/** Returns the unedited, unformatted raw actual value. */ protected final T actual() { return getSubject(); }
protected String getDisplaySubject() { return (customName == null) ? "<" + getSubject() + ">" : "\"" + this.customName + "\""; }
public void isEqualTo(Object other) { if (getSubject() == null) { if(other != null) { fail("is equal to", other); } } else { if (!getSubject().equals(other)) { fail("is equal to", other); } } }
public void isNotNull() { if (getSubject() == null) { failWithoutSubject("is a non-null reference"); } }
public void isNull() { if (getSubject() != null) { failWithoutSubject("is a null reference"); } }
public void isNotEqualTo(Object other) { if (getSubject() == null) { if(other == null) { fail("is not equal to", (Object)null); } } else { if (getSubject().equals(other)) { fail("is not equal to", other); } } }
public void isA(Class<?> clazz) { if (clazz == null) { throw new NullPointerException("clazz"); } if (!Platform.isInstanceOfType(getSubject(), clazz)) { if (getSubject() != null) { failWithBadResults("is an instance of", clazz.getName(), "is an instance of", getSubject().getClass().getName()); } else { fail("is an instance of", clazz.getName()); } } }
public void isNotA(Class<?> clazz) { if (clazz == null) { throw new NullPointerException("clazz"); } if (getSubject() == null) { return; // null is not an instance of clazz. } if (Platform.isInstanceOfType(getSubject(), clazz)) { failWithRawMessage("%s expected not to be an instance of %s, but was.", getDisplaySubject(), clazz.getName()); } }
@GwtIncompatible("java.lang.reflect.Field") public HasField hasField(final String fieldName) { final T subject = getSubject(); if (subject == null) { failureStrategy.fail("Cannot determine a field name from a null object.");