<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 testDeepMethodConflictProvidesSameValue() throws Exception {
    ProxyInvocationHandler handler = new ProxyInvocationHandler(Maps.newHashMap());
    DeepMethodConflict deepMethodConflict = handler.as(DeepMethodConflict.class);

    // Tests overriding an already overridden method
    deepMethodConflict.setString("conflictValue");
    assertEquals("conflictValue", deepMethodConflict.getString());
    assertEquals("conflictValue", deepMethodConflict.as(MethodConflict.class).getString());
    assertEquals("conflictValue", deepMethodConflict.as(Simple.class).getString());

    // Tests overriding a method from an ancestor class
    deepMethodConflict.setPrimitive(5);
    assertEquals(5, deepMethodConflict.getPrimitive());
    assertEquals(5, deepMethodConflict.as(MethodConflict.class).getPrimitive());
    assertEquals(5, deepMethodConflict.as(Simple.class).getPrimitive());
  }