@Override String reportItem(Item<?> item) { List<Object> factoryArgs = argGroups.get(item.groupNumber).get(item.itemNumber); return factory.getName() + "(" + Joiner.on(", ").useForNull("null").join(factoryArgs) + ")"; } });
@Override String reportItem(Item<?> item) { List<Object> factoryArgs = argGroups.get(item.groupNumber).get(item.itemNumber); return factory.getName() + "(" + Joiner.on(", ").useForNull("null").join(factoryArgs) + ")"; } });
public String apply(Invokable<?, ?> input) { return input.getName(); } };
/** * In JDK7 Closeable.close is declared in AutoCloseable, which throws * Exception vs IOException, so we have to be more lenient about exception * type declarations. * * <h4>note</h4> * * This will be refactored out when we delete Async code in jclouds 1.7. */ private static boolean isCloseable(Invokable<?, ?> delegatedMethod) { return "close".equals(delegatedMethod.getName()) && Closeable.class.isAssignableFrom(delegatedMethod.getDeclaringClass()); }
@Override String reportItem(Item<?> item) { List<Object> factoryArgs = argGroups.get(item.groupNumber).get(item.itemNumber); return factory.getName() + "(" + Joiner.on(", ").useForNull("null").join(factoryArgs) + ")"; } });
@Override public String toString() { String callerString = caller != null ? String.format("%s.%s%s", caller.getInvokable().getOwnerType().getRawType().getSimpleName(), caller.getInvokable().getName(), caller.getArgs()) : null; return MoreObjects.toStringHelper("").omitNullValues().add("caller", callerString).toString(); } }
@Override public String getCommandName(Invocation invocation) { Invokable<?, ?> invoked = invocation.getInvokable(); if (invoked.isAnnotationPresent(Named.class)) { return invoked.getAnnotation(Named.class).value(); } else { // TODO: remove old logic once Named annotations are on all methods String className = invoked.getOwnerType().getRawType().getSimpleName().replace("AsyncClient", "Client") .replace("AsyncApi", "Api"); return className + "." + invoked.getName(); } }
@Override public String toString() { String callerString = caller != null ? String.format("%s.%s%s", caller.getInvokable().getOwnerType().getRawType().getSimpleName(), caller.getInvokable().getName(), caller.getArgs()) : null; return Objects.toStringHelper("").omitNullValues().add("caller", callerString).toString(); } }
@Override public String toString() { String callerString = caller != null ? String.format("%s.%s%s", caller.getInvokable().getOwnerType().getRawType().getSimpleName(), caller.getInvokable().getName(), caller.getArgs()) : null; return Objects.toStringHelper("").omitNullValues().add("caller", callerString).toString(); } }
@Override public String toString() { String callerString = caller != null ? String.format("%s.%s%s", caller.getInvokable().getOwnerType().getRawType().getSimpleName(), caller.getInvokable().getName(), caller.getArgs()) : null; return Objects.toStringHelper("").omitNullValues().add("caller", callerString).toString(); } }
@Override public String getCommandName(Invocation invocation) { Invokable<?, ?> invoked = invocation.getInvokable(); if (invoked.isAnnotationPresent(Named.class)) { return invoked.getAnnotation(Named.class).value(); } else { // TODO: remove old logic once Named annotations are on all methods String className = invoked.getOwnerType().getRawType().getSimpleName(); return className + "." + invoked.getName(); } }
private boolean checkPresentOrNullable(Invocation invocation, String paramKey, int argIndex, Object arg) { if (arg == null && !invocation.getInvokable().getParameters().get(argIndex).isAnnotationPresent(Nullable.class)) throw new NullPointerException(format("param{%s} for invocation %s.%s", paramKey, invocation.getInvokable() .getOwnerType().getRawType().getSimpleName(), invocation.getInvokable().getName())); return true; }
private boolean checkPresentOrNullable(Invocation invocation, String paramKey, int argIndex, Object arg) { if (arg == null && !getInvokableParameters(invocation.getInvokable()).get(argIndex).isAnnotationPresent(Nullable.class)) throw new NullPointerException(format("param{%s} for invocation %s.%s", paramKey, invocation.getInvokable() .getOwnerType().getRawType().getSimpleName(), invocation.getInvokable().getName())); return true; }
private boolean checkPresentOrNullable(Invocation invocation, String paramKey, int argIndex, Object arg) { if (arg == null && !getInvokableParameters(invocation.getInvokable()).get(argIndex).isAnnotationPresent(Nullable.class)) throw new NullPointerException(format("param{%s} for invocation %s.%s", paramKey, invocation.getInvokable() .getOwnerType().getRawType().getSimpleName(), invocation.getInvokable().getName())); return true; }
private boolean checkPresentOrNullable(Invocation invocation, String paramKey, int argIndex, Object arg) { if (arg == null && !invocation.getInvokable().getParameters().get(argIndex).isAnnotationPresent(Nullable.class)) throw new NullPointerException(format("param{%s} for invocation %s.%s", paramKey, invocation.getInvokable() .getOwnerType().getRawType().getSimpleName(), invocation.getInvokable().getName())); return true; }
public static void putInvokables(Class<?> sync, Class<?> async, Cache<Invokable<?, ?>, Invokable<?, ?>> cache) { for (Invokable<?, ?> invoked : methods(sync)) { Invokable<?, ?> delegatedMethod = method(async, invoked.getName(), getParameterTypes(invoked)); checkArgument(delegatedMethod.getExceptionTypes().equals(invoked.getExceptionTypes()) || isCloseable(delegatedMethod), "invoked %s has different typed exceptions than target %s", invoked, delegatedMethod); cache.put(invoked, delegatedMethod); } }
public static void putInvokables(Class<?> sync, Class<?> async, Cache<Invokable<?, ?>, Invokable<?, ?>> cache) { for (Invokable<?, ?> invoked : methods(sync)) { Invokable<?, ?> delegatedMethod = method(async, invoked.getName(), getParameterTypes(invoked)); checkArgument(delegatedMethod.getExceptionTypes().equals(invoked.getExceptionTypes()) || isCloseable(delegatedMethod), "invoked %s has different typed exceptions than target %s", invoked, delegatedMethod); cache.put(invoked, delegatedMethod); } }