public void testIsReturnTypeOptionalWhenNotOptional() throws SecurityException, NoSuchMethodException { Invokable<?, ?> invoked = method(Test.class, "getNotOptional"); assertFalse(Optionals2.isReturnTypeOptional(invoked)); } }
public void testIsReturnTypeOptionalWhenOptional() throws SecurityException, NoSuchMethodException { Invokable<?, ?> invoked = method(Test.class, "getOptional"); assertTrue(Optionals2.isReturnTypeOptional(invoked)); }
public void testIsReturnTypeOptionalWhenNotOptional() throws SecurityException, NoSuchMethodException { Invokable<?, ?> invoked = method(Test.class, "getNotOptional"); assertFalse(Optionals2.isReturnTypeOptional(invoked)); } }
public void testIsReturnTypeOptionalWhenOptional() throws SecurityException, NoSuchMethodException { Invokable<?, ?> invoked = method(Test.class, "getOptional"); assertTrue(Optionals2.isReturnTypeOptional(invoked)); }
private Object propagateContextToDelegate(Invocation caller) { Class<?> returnType = unwrapIfOptional(caller.getInvokable().getReturnType()); Function<Invocation, Object> delegate; setCaller.enter(caller); try { @SuppressWarnings("unchecked") Key<Function<Invocation, Object>> delegateType = (Key<Function<Invocation, Object>>) methodInvokerFor(returnType); delegate = injector.getInstance(delegateType); } finally { setCaller.exit(); } Object result = FunctionalReflection.newProxy(returnType, delegate); if (isReturnTypeOptional(caller.getInvokable())) { result = optionalConverter.apply(InvocationSuccess.create(caller, result)); } return result; }
private Object propagateContextToDelegate(Invocation caller) { Class<?> returnType = unwrapIfOptional(caller.getInvokable().getReturnType()); Function<Invocation, Object> delegate; setCaller.enter(caller); try { @SuppressWarnings("unchecked") Key<Function<Invocation, Object>> delegateType = (Key<Function<Invocation, Object>>) methodInvokerFor(returnType); delegate = injector.getInstance(delegateType); } finally { setCaller.exit(); } Object result = FunctionalReflection.newProxy(returnType, delegate); if (isReturnTypeOptional(caller.getInvokable())) { result = optionalConverter.apply(InvocationSuccess.create(caller, result)); } return result; }
private Object propagateContextToDelegate(Invocation caller) { Class<?> returnType = unwrapIfOptional(caller.getInvokable().getReturnType()); Function<Invocation, Object> delegate; setCaller.enter(caller); try { @SuppressWarnings("unchecked") Key<Function<Invocation, Object>> delegateType = (Key<Function<Invocation, Object>>) methodInvokerFor(returnType); delegate = injector.getInstance(delegateType); } finally { setCaller.exit(); } Object result = FunctionalReflection.newProxy(returnType, delegate); if (isReturnTypeOptional(caller.getInvokable())) { result = optionalConverter.apply(InvocationSuccess.create(caller, result)); } return result; }
private Object propagateContextToDelegate(Invocation caller) { Class<?> returnType = unwrapIfOptional(caller.getInvokable().getReturnType()); Function<Invocation, Object> delegate; setCaller.enter(caller); try { @SuppressWarnings("unchecked") Key<Function<Invocation, Object>> delegateType = (Key<Function<Invocation, Object>>) methodInvokerFor(returnType); delegate = injector.getInstance(delegateType); } finally { setCaller.exit(); } Object result = FunctionalReflection.newProxy(returnType, delegate); if (isReturnTypeOptional(caller.getInvokable())) { result = optionalConverter.apply(InvocationSuccess.create(caller, result)); } return result; }
private Object propagateContextToDelegate(Invocation caller) { Class<?> returnType = unwrapIfOptional(caller.getInvokable().getReturnType()); Function<Invocation, Object> delegate; setCaller.enter(caller); try { @SuppressWarnings("unchecked") Key<Function<Invocation, Object>> delegateType = (Key<Function<Invocation, Object>>) methodInvokerFor(returnType); delegate = injector.getInstance(delegateType); } finally { setCaller.exit(); } Object result = FunctionalReflection.newProxy(returnType, delegate); if (isReturnTypeOptional(caller.getInvokable())) { result = optionalConverter.apply(InvocationSuccess.create(caller, result)); } return result; }
private Object propagateContextToDelegate(Invocation caller) { Class<?> returnType = unwrapIfOptional(caller.getInvokable().getReturnType()); Function<Invocation, Object> delegate; setCaller.enter(caller); try { @SuppressWarnings("unchecked") Key<Function<Invocation, Object>> delegateType = (Key<Function<Invocation, Object>>) methodInvokerFor(returnType); delegate = injector.getInstance(delegateType); } finally { setCaller.exit(); } Object result = FunctionalReflection.newProxy(returnType, delegate); if (isReturnTypeOptional(caller.getInvokable())) { result = optionalConverter.apply(InvocationSuccess.create(caller, result)); } return result; }