io.micronaut.core.type.Argument.of()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中io.micronaut.core.type.Argument.of()方法的一些代码示例,展示了Argument.of()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Argument.of()方法的具体详情如下:
包路径:io.micronaut.core.type.Argument
类名称:Argument
方法名:of

Argument.of介绍

[英]Creates a new argument for the given type and name.
[中]为给定类型和名称创建新参数。

代码示例

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Creates a new argument representing a generic set.
 *
 * @param type set element type
 * @param <T>  set element type
 * @return The argument instance
 */
static <T> Argument<Set<T>> setOf(Class<T> type) {
  //noinspection unchecked
  return of((Class<Set<T>>) ((Class) Set.class), type);
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public Argument<CompletableFuture> argumentType() {
  return Argument.of(CompletableFuture.class);
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Creates a new argument representing a generic list.
 *
 * @param type list element type
 * @param <T>  list element type
 * @return The argument instance
 */
static <T> Argument<List<T>> listOf(Class<T> type) {
  //noinspection unchecked
  return of((Class<List<T>>) ((Class) List.class), type);
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public Argument<Publisher> argumentType() {
  return Argument.of(Publisher.class);
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Decode the given type from the given {@link InputStream}.
 *
 * @param type        The type
 * @param inputStream The input stream
 * @param <T>         The generic type
 * @return The decoded result
 * @throws CodecException When the result cannot be decoded
 */
default <T> T decode(Class<T> type, InputStream inputStream) throws CodecException {
  return decode(Argument.of(type), inputStream);
}

代码示例来源:origin: micronaut-projects/micronaut-core

@SuppressWarnings("unchecked")
@Override
public <T1> Optional<T1> getBody(Class<T1> type) {
  return getBody(Argument.of(type));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Create a simple {@link ConversionContext} for the given generic type variables.
 *
 * @param <T>      type Generic
 * @param argument The argument
 * @return The conversion context
 */
static <T> ArgumentConversionContext<T> of(Class<T> argument) {
  return of(Argument.of(argument), null, null);
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Returns a submap for all the keys with the given prefix.
 *
 * @param prefix    The prefix
 * @param valueType The value type
 * @return The submap
 */
@SuppressWarnings("unchecked")
default Map<String, V> subMap(String prefix, Class<V> valueType) {
  return subMap(prefix, Argument.of(valueType));
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public <T> Optional<T> getBody(Class<T> type) {
  if (type == null) {
    return Optional.empty();
  }
  return getBody(Argument.of(type));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Find a header and convert it to the given type.
 *
 * @param name         The name of the header
 * @param requiredType The required type
 * @param <T>          The generic type
 * @return If the header is presented and can be converted an optional of the value otherwise {@link Optional#empty()}
 */
default <T> Optional<T> getFirst(CharSequence name, Class<T> requiredType) {
  return getFirst(name, Argument.of(requiredType));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Perform an HTTP request for the given request object emitting the full HTTP response from returned
 * {@link org.reactivestreams.Publisher} and converting the response body to the specified type.
 *
 * @param request  The {@link HttpRequest} to execute
 * @param bodyType The body type
 * @param <I>      The request body type
 * @param <O>      The response body type
 * @return The full {@link HttpResponse} object
 */
default <I, O> HttpResponse<O> exchange(HttpRequest<I> request, Class<O> bodyType) {
  return exchange(request, Argument.of(bodyType));
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public <I, O> Flowable<O> jsonStream(io.micronaut.http.HttpRequest<I> request, Class<O> type) {
  return jsonStream(request, io.micronaut.core.type.Argument.of(type));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Perform an HTTP request for the given request object emitting the full HTTP response from returned
 * {@link Publisher} and converting the response body to the specified type.
 *
 * @param request  The {@link HttpRequest} to execute
 * @param bodyType The body type
 * @param <I>      The request body type
 * @param <O>      The response body type
 * @return A {@link Publisher} that emits a result of the given type
 */
default <I, O> Publisher<O> retrieve(HttpRequest<I> request, Class<O> bodyType) {
  return retrieve(request, Argument.of(bodyType));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Get the value of the given annotation member.
 *
 * @param annotation   The annotation class
 * @param member       The annotation member
 * @param requiredType The required type
 * @param <T>          The value
 * @return An {@link Optional} of the value
 */
default @Nonnull <T> Optional<T> getValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, @Nonnull Class<T> requiredType) {
  ArgumentUtils.requireNonNull("requiredType", requiredType);
  return getValue(annotation, member, Argument.of(requiredType));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Return the body as the given type.
 *
 * @param type The type of the body
 * @param <T>  The generic type
 * @return An {@link Optional} of the type or {@link Optional#empty()} if the body cannot be returned as the given type
 */
default @Nonnull <T> Optional<T> getBody(@Nonnull Class<T> type) {
  ArgumentUtils.requireNonNull("type", type);
  return getBody(Argument.of(type));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * @return The return type as an argument
 */
default Argument<T> asArgument() {
  Collection<Argument<?>> values = getTypeVariables().values();
  return Argument.of(getType(), values.toArray(new Argument[0]));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Resolve the given property for the given name.
 *
 * @param name         The name
 * @param requiredType The required type
 * @param <T>          The concrete type
 * @return An optional containing the property value if it exists and is able to be converted
 */
default <T> Optional<T> get(K name, Class<T> requiredType) {
  return get(name, ConversionContext.of(Argument.of(requiredType)));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Perform an HTTP GET request for the given request object emitting the full HTTP response from returned
 * {@link Publisher}.
 *
 * @param uri      The request URI
 * @param bodyType The body type
 * @param <O>      The response body type
 * @return A {@link Publisher} that emits the full {@link HttpResponse} object
 */
default <O> Publisher<HttpResponse<O>> exchange(String uri, Class<O> bodyType) {
  return exchange(HttpRequest.GET(uri), Argument.of(bodyType));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * Perform a GET request for the given request object emitting the full HTTP response from returned
 * {@link org.reactivestreams.Publisher}.
 *
 * @param uri      The URI of the GET request
 * @param <O>      The response body type
 * @param bodyType The body type
 * @return The full {@link HttpResponse} object
 */
default <O> HttpResponse<O> exchange(String uri, Class<O> bodyType) {
  return exchange(HttpRequest.GET(uri), Argument.of(bodyType));
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * <p>Perform an HTTP GET request and receive data as a stream of SSE {@link Event} objects as they become available without blocking.</p>
 * <p>
 * <p>The downstream {@link org.reactivestreams.Subscriber} can regulate demand via the subscription</p>
 *
 * @param uri The request URI
 * @param eventType The event data type
 * @param <B> The event body type
 * @return A {@link Publisher} that emits an {@link Event} with the data represented by the eventType argument
 */
default <B> Publisher<Event<B>> eventStream(String uri, Class<B> eventType) {
  return eventStream(HttpRequest.GET(uri), Argument.of(eventType));
}

相关文章