Versioned { public static <U> U valueOrElse(final Versioned<U> versioned, final U defaultValue) { return versioned == null ? defaultValue : versioned.value(); } Versioned(final V value, final long version, final long creationTime);  Versioned(final V value, final long version); V value(); long version(); long creationTime(); synchronized Versioned<U> map(final Function<V, U> transformer); static U valueOrElse(final Versioned<U> versioned, final U defaultValue); static U valueOrNull(final Versioned<U> versioned); @Override int hashCode(); @Override boolean equals(final Object other); @Override String toString();  }
@Test public void testOrElse() { final Versioned<String> vv = new Versioned<>("foo", 1); final Versioned<String> nullVV = null; assertThat(Versioned.valueOrElse(vv, "bar"), is("foo")); assertThat(Versioned.valueOrElse(nullVV, "bar"), is("bar")); }