@Repeatable(value=ContainerMethod.List.class) @Documented @Target(value={ANNOTATION_TYPE,METHOD,TYPE}) @Retention(value=RUNTIME) public @interface ContainerMethod
Indicates that the annotation or the method pointed to by the annotation can be converted to a method container of the specified type. The annotated method needs to meet the following requirements:
type() is MappingType.NO_MAPPING, the return value type must be Map;type() is not MappingType.NO_MAPPING,
the return value can be a single object, array or Collection;
For example, the following example describes how to adapt the requestFoo() method to a data source container:
The first way is to add annotations directly on the method:
{@codecn.crane4j.core.support.container.DefaultMethodContainerFactory,
cn.crane4j.core.support.container.ContainerMethodAnnotationProcessor| 限定符和类型 | 可选元素和说明 |
|---|---|
String |
bindMethod
The name of method which will be used to adapt the method container.
|
Class<?>[] |
bindMethodParamTypes
The parameter types of the method which will be used to adapt the method container.
|
DuplicateStrategy |
duplicateStrategy
The strategy for handling duplicate keys.
|
String |
namespace
Namespace of the data source container, use method name when empty.
|
String |
on
When the return value is a wrapper class,
we can specify to obtain the dataset to be processed
from the specific field of the wrapper class,
and then use it to be data source of the container.
|
String |
resultKey
The key field of the data source object returned by the method.
|
Class<?> |
resultType
Data source object type returned by method.
|
MappingType |
type
The mapping relationship between the object returned by the method and the target object.
|
public abstract String namespace
public abstract MappingType type
public abstract DuplicateStrategy duplicateStrategy
public abstract String resultKey
type() is MappingType.NO_MAPPING or MappingType.ORDER_OF_KEYS,
this parameter is ignored.public abstract Class<?> resultType
type() is MappingType.NO_MAPPING or MappingType.ORDER_OF_KEYS,
this parameter is ignored.public abstract String bindMethod
namespace()public abstract Class<?>[] bindMethodParamTypes
public abstract String on
When the return value is a wrapper class, we can specify to obtain the dataset to be processed from the specific field of the wrapper class, and then use it to be data source of the container.
For example:
// general response public static class Result{ private Integer code; private T data; // objects to be processed } // process general response
AutoOperate.on()Copyright © 2024. All rights reserved.