public boolean apply(Invokable<?, ?> in) { return in.isAnnotationPresent(PostConstruct.class); } };
@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(); } }
@SuppressWarnings("unchecked") private static Key<? extends Function<HttpResponse, ?>> getJAXBParserKeyForMethod(Invokable<?, ?> invoked) { Optional<Type> configuredReturnVal = Optional.absent(); if (invoked.isAnnotationPresent(JAXBResponseParser.class)) { Type configuredClass = invoked.getAnnotation(JAXBResponseParser.class).value(); configuredReturnVal = configuredClass.equals(NullType.class) ? Optional.<Type> absent() : Optional .<Type> of(configuredClass); } Type returnVal = configuredReturnVal.or(getReturnTypeFor(invoked.getReturnType())); Type parserType = newParameterizedType(ParseXMLWithJAXB.class, returnVal); return (Key<? extends Function<HttpResponse, ?>>) Key.get(parserType); }
@SuppressWarnings("unchecked") private static Key<? extends Function<HttpResponse, ?>> getJAXBParserKeyForMethod(Invokable<?, ?> invoked) { Optional<Type> configuredReturnVal = Optional.absent(); if (invoked.isAnnotationPresent(JAXBResponseParser.class)) { Type configuredClass = invoked.getAnnotation(JAXBResponseParser.class).value(); configuredReturnVal = configuredClass.equals(NullType.class) ? Optional.<Type> absent() : Optional .<Type> of(configuredClass); } Type returnVal = configuredReturnVal.or(getReturnTypeFor(invoked.getReturnType())); Type parserType = newParameterizedType(ParseXMLWithJAXB.class, returnVal); return (Key<? extends Function<HttpResponse, ?>>) Key.get(parserType); }
private static Optional<String> getAnnotatedApiVersion(Invocation invocation) { final Invokable<?, ?> invokable = invocation.getInvokable(); if (invokable.isAnnotationPresent(ApiVersionOverride.class)) { return Optional.fromNullable(invokable.getAnnotation(ApiVersionOverride.class).value()); } else { final Class<?> owner = invokable.getOwnerType().getRawType(); if (owner.isAnnotationPresent(ApiVersionOverride.class)) { return Optional.fromNullable(owner.getAnnotation(ApiVersionOverride.class).value()); } } return Optional.absent(); }
private boolean shouldAddHostHeader(Invocation invocation) { return invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(VirtualHost.class) || invocation .getInvokable().isAnnotationPresent(VirtualHost.class); }
@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 Multimap<String, Object> addPathAndGetTokens(Invocation invocation, UriBuilder uriBuilder) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Path.class)) uriBuilder.appendPath(invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Path.class).value()); if (invocation.getInvokable().isAnnotationPresent(Path.class)) uriBuilder.appendPath(invocation.getInvokable().getAnnotation(Path.class).value()); return getPathParamKeyValues(invocation); }
private Multimap<String, Object> addPathAndGetTokens(Invocation invocation, UriBuilder uriBuilder) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Path.class)) uriBuilder.appendPath(invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Path.class).value()); if (invocation.getInvokable().isAnnotationPresent(Path.class)) uriBuilder.appendPath(invocation.getInvokable().getAnnotation(Path.class).value()); return getPathParamKeyValues(invocation); }
private Multimap<String, Object> addPathAndGetTokens(Invocation invocation, UriBuilder uriBuilder) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Path.class)) uriBuilder.appendPath(invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Path.class).value()); if (invocation.getInvokable().isAnnotationPresent(Path.class)) uriBuilder.appendPath(invocation.getInvokable().getAnnotation(Path.class).value()); return getPathParamKeyValues(invocation); }
private void addProducesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invocation invocation) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } if (invocation.getInvokable().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } }
private void addProducesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invocation invocation) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } if (invocation.getInvokable().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } }
private void addHeaderIfAnnotationPresentOnMethod(Multimap<String, String> headers, Invocation invocation, Multimap<String, ?> tokenValues) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Headers.class)) { Headers header = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Headers.class); addHeader(headers, header, tokenValues); } if (invocation.getInvokable().isAnnotationPresent(Headers.class)) { Headers header = invocation.getInvokable().getAnnotation(Headers.class); addHeader(headers, header, tokenValues); } }
private void addProducesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invocation invocation) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } if (invocation.getInvokable().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } }
private void addProducesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invocation invocation) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } if (invocation.getInvokable().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } }
private void addProducesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invocation invocation) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } if (invocation.getInvokable().isAnnotationPresent(Produces.class)) { Produces header = invocation.getInvokable().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } }
private void addHeaderIfAnnotationPresentOnMethod(Multimap<String, String> headers, Invocation invocation, Multimap<String, ?> tokenValues) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(Headers.class)) { Headers header = invocation.getInvokable().getOwnerType().getRawType().getAnnotation(Headers.class); addHeader(headers, header, tokenValues); } if (invocation.getInvokable().isAnnotationPresent(Headers.class)) { Headers header = invocation.getInvokable().getAnnotation(Headers.class); addHeader(headers, header, tokenValues); } }
@SuppressWarnings({ "unchecked" }) private static Key<? extends Function<HttpResponse, ?>> getJsonParserKeyForMethod(Invokable<?, ?> invoked) { ParameterizedType parserType; if (invoked.isAnnotationPresent(Unwrap.class)) { parserType = newParameterizedType(UnwrapOnlyJsonValue.class, getReturnTypeFor(invoked.getReturnType())); } else { parserType = newParameterizedType(ParseJson.class, getReturnTypeFor(invoked.getReturnType())); } return (Key<? extends Function<HttpResponse, ?>>) Key.get(parserType); }
private void overridePathEncoding(UriBuilder uriBuilder, Invocation invocation) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(SkipEncoding.class)) { uriBuilder.skipPathEncoding(Chars.asList(invocation.getInvokable().getOwnerType().getRawType() .getAnnotation(SkipEncoding.class).value())); } if (invocation.getInvokable().isAnnotationPresent(SkipEncoding.class)) { uriBuilder.skipPathEncoding(Chars.asList(invocation.getInvokable().getAnnotation(SkipEncoding.class).value())); } }
private void overridePathEncoding(UriBuilder uriBuilder, Invocation invocation) { if (invocation.getInvokable().getOwnerType().getRawType().isAnnotationPresent(SkipEncoding.class)) { uriBuilder.skipPathEncoding(Chars.asList(invocation.getInvokable().getOwnerType().getRawType() .getAnnotation(SkipEncoding.class).value())); } if (invocation.getInvokable().isAnnotationPresent(SkipEncoding.class)) { uriBuilder.skipPathEncoding(Chars.asList(invocation.getInvokable().getAnnotation(SkipEncoding.class).value())); } }