<T extends PipelineOptions> T as(Class<T> iface) {
    checkNotNull(iface);
    checkArgument(iface.isInterface(), "Not an interface: %s", iface);

    T existingOption = computedProperties.interfaceToProxyCache.getInstance(iface);
    if (existingOption == null) {
      synchronized (this) {
        // double check
        existingOption = computedProperties.interfaceToProxyCache.getInstance(iface);
        if (existingOption == null) {
          Registration<T> registration =
              PipelineOptionsFactory.CACHE
                  .get()
                  .validateWellFormed(iface, computedProperties.knownInterfaces);
          List<PropertyDescriptor> propertyDescriptors = registration.getPropertyDescriptors();

          Class<T> proxyClass = registration.getProxyClass();

          existingOption =
              InstanceBuilder.ofType(proxyClass)
                  .fromClass(proxyClass)
                  .withArg(InvocationHandler.class, this)
                  .build();

          computedProperties =
              computedProperties.updated(iface, existingOption, propertyDescriptors);
        }
      }
    }
    return existingOption;
  }
@Test
  public void testDisplayDataDeserializationWithRegistration() throws Exception {
    PipelineOptionsFactory.register(HasClassOptions.class);
    HasClassOptions options = PipelineOptionsFactory.as(HasClassOptions.class);
    options.setClassOption(ProxyInvocationHandlerTest.class);

    PipelineOptions deserializedOptions = serializeDeserialize(PipelineOptions.class, options);
    DisplayData displayData = DisplayData.from(deserializedOptions);
    assertThat(displayData, hasDisplayItem("classOption", ProxyInvocationHandlerTest.class));
  }