class Protected {

  public static <J extends JsonDdlObject<J>> J object(J value) {
    if (value instanceof JsonDdlObject.Builder) {
      return ((JsonDdlObject.Builder<J>) value).build();
    }
    return value;
  }

}

class ProtectedTest {

  @Test
  @SuppressWarnings({ "rawtypes", "unchecked" })

  public void testJsonDdlObject() {
    JsonDdlObject<?> obj = createStrictMock(JsonDdlObject.class);
    JsonDdlObject.Builder builder = createStrictMock(JsonDdlObject.Builder.class);
    expect(builder.build()).andReturn(obj).times(2);
    replay(obj, builder);

    assertSame(obj, Protected.object((Object) obj));
    assertSame(obj, Protected.object((Object) builder));
    assertSame(obj, Protected.object((JsonDdlObject) obj));
    assertSame(obj, Protected.object((JsonDdlObject) builder));

    verify(obj, builder);
  }

}