@Test @SuppressWarnings("SelfEquals") public void shouldAllowObjectMethodsWhenLeading() { Runnable proxy = AwaitingLeadershipProxy.newProxyInstance( Runnable.class, delegateSupplier, leaderElectionService); assertThat(proxy.hashCode()).isNotNull(); assertThat(proxy.equals(proxy)).isTrue(); assertThat(proxy.equals(null)).isFalse(); assertThat(proxy.toString()).startsWith("com.palantir.leader.proxy.AwaitingLeadershipProxy@"); }
public static <U> U newProxyInstance(Class<U> interfaceClass, Supplier<U> delegateSupplier, LeaderElectionService leaderElectionService) { AwaitingLeadershipProxy<U> proxy = new AwaitingLeadershipProxy<>( delegateSupplier, leaderElectionService, interfaceClass); proxy.tryToGainLeadership(); return (U) Proxy.newProxyInstance( interfaceClass.getClassLoader(), new Class<?>[] { interfaceClass, Closeable.class }, proxy); }
AwaitingLeadershipProxy extends AbstractInvocationHandler { public static <U> U newProxyInstance(Class<U> interfaceClass, Supplier<U> delegateSupplier, LeaderElectionService leaderElectionService) { AwaitingLeadershipProxy<U> proxy = new AwaitingLeadershipProxy<>( delegateSupplier, leaderElectionService, interfaceClass); proxy.tryToGainLeadership(); return (U) Proxy.newProxyInstance( interfaceClass.getClassLoader(), new Class<?>[] { interfaceClass, Closeable.class }, proxy); } }
AwaitingLeadershipProxy extends AbstractInvocationHandler { public static <U> U newProxyInstance(Class<U> interfaceClass, Supplier<U> delegateSupplier, LeaderElectionService leaderElectionService) { AwaitingLeadershipProxy<U> proxy = new AwaitingLeadershipProxy<>( delegateSupplier, leaderElectionService, interfaceClass); proxy.tryToGainLeadership(); return (U) Proxy.newProxyInstance( interfaceClass.getClassLoader(), new Class<?>[] { interfaceClass, Closeable.class }, proxy); } private  AwaitingLeadershipProxy(
            Supplier<T> delegateSupplier,
            LeaderElectionService leaderElectionService,
            Class<T> interfaceClass); }
AwaitingLeadershipProxy extends AbstractInvocationHandler { public static <U> U newProxyInstance(Class<U> interfaceClass, Supplier<U> delegateSupplier, LeaderElectionService leaderElectionService) { AwaitingLeadershipProxy<U> proxy = new AwaitingLeadershipProxy<>( delegateSupplier, leaderElectionService, interfaceClass); proxy.tryToGainLeadership(); return (U) Proxy.newProxyInstance( interfaceClass.getClassLoader(), new Class<?>[] { interfaceClass, Closeable.class }, proxy); } private  AwaitingLeadershipProxy(
            Supplier<T> delegateSupplier,
            LeaderElectionService leaderElectionService,
            Class<T> interfaceClass); static U newProxyInstance(Class<U> interfaceClass,
                                         Supplier<U> delegateSupplier,
                                         LeaderElectionService leaderElectionService); }
AwaitingLeadershipProxy extends AbstractInvocationHandler { public static <U> U newProxyInstance(Class<U> interfaceClass, Supplier<U> delegateSupplier, LeaderElectionService leaderElectionService) { AwaitingLeadershipProxy<U> proxy = new AwaitingLeadershipProxy<>( delegateSupplier, leaderElectionService, interfaceClass); proxy.tryToGainLeadership(); return (U) Proxy.newProxyInstance( interfaceClass.getClassLoader(), new Class<?>[] { interfaceClass, Closeable.class }, proxy); } private  AwaitingLeadershipProxy(
            Supplier<T> delegateSupplier,
            LeaderElectionService leaderElectionService,
            Class<T> interfaceClass); static U newProxyInstance(Class<U> interfaceClass,
                                         Supplier<U> delegateSupplier,
                                         LeaderElectionService leaderElectionService);  }