@SuppressWarnings("unchecked") public static <T> T getProxyForHandler(GrapheneProxyHandler handler, Class<?> baseType, Class<?>... additionalInterfaces) { return (T) createProxy(handler, baseType, additionalInterfaces); }
@SuppressWarnings("unchecked") public static <T> T getProxyForHandler(GrapheneProxyHandler handler, Class<?> baseType, Class<?>... additionalInterfaces) { return (T) createProxy(handler, baseType, additionalInterfaces); }
/** * <p> * Wraps the given target instance in the proxy. * </p> * * <p> * The list of interfaces which should be implemented by the proxy needs to be provided. * </p> * * * @param target the target instance to be wrapped * @param interfaces the list of interfaces which should be implemented by created proxy * @return the proxy wrapping the target */ @SuppressWarnings("unchecked") public static <T> T getProxyForTargetWithInterfaces(GrapheneContext context, T target, Class<?>... interfaces) { GrapheneProxyHandler handler = GrapheneContextualHandler.forTarget(context, target); return (T) createProxy(handler, null, interfaces); }
/** * <p> * Wraps the given target instance in the proxy. * </p> * * <p> * The list of interfaces which should be implemented by the proxy needs to be provided. * </p> * * * @param target the target instance to be wrapped * @param interfaces the list of interfaces which should be implemented by created proxy * @return the proxy wrapping the target */ @SuppressWarnings("unchecked") public static <T> T getProxyForTargetWithInterfaces(GrapheneContext context, T target, Class<?>... interfaces) { GrapheneProxyHandler handler = GrapheneContextualHandler.forTarget(context, target); return (T) createProxy(handler, null, interfaces); }
/** * <p> * Wraps the given target instance in the proxy. * </p> * * <p> * The list of interfaces which should be implemented by the proxy is automatically computer from provided instance. * </p> * * * @param target the target instance to be wrapped * @return the proxy wrapping the target */ @SuppressWarnings("unchecked") public static <T> T getProxyForTarget(GrapheneContext context, T target) { if (Modifier.isFinal(target.getClass().getModifiers())) { if (target.getClass().getInterfaces().length > 0) { return GrapheneProxy.getProxyForTargetWithInterfaces(context, target, target.getClass().getInterfaces()); } else { throw new IllegalStateException("Can't create a proxy for " + target.getClass() + ", it's final and id doesn't implement any interface."); } } GrapheneProxyHandler handler = GrapheneContextualHandler.forTarget(context, target); return (T) createProxy(handler, target.getClass()); }
/** * <p> * Wraps the given target instance in the proxy. * </p> * * <p> * The list of interfaces which should be implemented by the proxy is automatically computer from provided instance. * </p> * * * @param target the target instance to be wrapped * @return the proxy wrapping the target */ @SuppressWarnings("unchecked") public static <T> T getProxyForTarget(GrapheneContext context, T target) { if (Modifier.isFinal(target.getClass().getModifiers())) { if (target.getClass().getInterfaces().length > 0) { return GrapheneProxy.getProxyForTargetWithInterfaces(context, target, target.getClass().getInterfaces()); } else { throw new IllegalStateException("Can't create a proxy for " + target.getClass() + ", it's final and id doesn't implement any interface."); } } GrapheneProxyHandler handler = GrapheneContextualHandler.forTarget(context, target); return (T) createProxy(handler, target.getClass()); }