コード例 #1
0
  public final <T> T createStableValue(final Factory<T> provider, final Condition<T> validator) {
    final T initial = provider.create();
    assert initial != null;
    final StableInvocationHandler handler =
        new StableInvocationHandler<T>(initial, provider, validator);

    final Set<Class> intf = new HashSet<Class>();
    ContainerUtil.addAll(intf, initial.getClass().getInterfaces());
    intf.add(StableElement.class);
    //noinspection unchecked

    return (T)
        AdvancedProxy.createProxy(
            initial.getClass().getSuperclass(), intf.toArray(new Class[intf.size()]), handler);
  }
コード例 #2
0
 @Nullable
 public static DomInvocationHandler getDomInvocationHandler(DomElement proxy) {
   if (proxy instanceof DomFileElement) {
     return null;
   }
   if (proxy instanceof DomInvocationHandler) {
     return (DomInvocationHandler) proxy;
   }
   final InvocationHandler handler = AdvancedProxy.getInvocationHandler(proxy);
   if (handler instanceof StableInvocationHandler) {
     final DomElement element =
         ((StableInvocationHandler<DomElement>) handler).getWrappedElement();
     return element == null ? null : getDomInvocationHandler(element);
   }
   if (handler instanceof DomInvocationHandler) {
     return (DomInvocationHandler) handler;
   }
   return null;
 }
コード例 #3
0
 public static StableInvocationHandler getStableInvocationHandler(Object proxy) {
   return (StableInvocationHandler) AdvancedProxy.getInvocationHandler(proxy);
 }