Objects example

To string helper

@Test
public void to_string_helper () {

    String overRideToString = Objects.toStringHelper(this)
            .add("name", "value")
            .toString();

    assertEquals("ObjectsExample{name=value}", overRideToString);
}

Equal

@Test
public void objects_equals () {

    String value1 = "Ice cold beer fest";
    String value2 = "Ice cold beer fest 2013";

    boolean objectEqual = Objects.equal(value1, value2);
    assertFalse(objectEqual);
}

First non null

@Test
public void first_non_null () {

    String first = null;
    String second = "What's shakin' bacon?";

    String firstNullObject = Objects.firstNonNull(first, second);

    assertEquals(second, firstNullObject);
}

Hash code

@Test
public void object_hashcode () {

    int hashCode = Objects.hashCode(this);

    assertEquals(anyInt(), hashCode);
}