All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jianggujin.http.support.annotation.JRequestParam Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2018 jianggujin (www.jianggujin.com).
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jianggujin.http.support.annotation;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.util.Map;

/**
 * 请求参数
 * 

* 当注解为类注解,则{@link #required()}无效, * 会根据{@link #itemDelimiter()}与{@link #kvDelimiter()}的配置对{@link #value()}进行拆分 *

*

* 当注解为方法注解,则{@link #required()}无效, * 会根据{@link #itemDelimiter()}与{@link #kvDelimiter()}的配置对{@link #value()}进行拆分 *

*

* 当注解为方法参数注解,则{@link #itemDelimiter()}与{@link #kvDelimiter()}的配置无效, * 如果方法参数类型为{@link String},则{@link #value()}必须配置,对应值为请求参数名称,方法参数为请求参数值; * 如果方法参数类型为{@link Map},则所有参数无效,方法参数即为请求参数 *

*

* 注解解析顺序为类注解 -> 方法注解 -> 方法参数注解。除方法参数注解外,同名参数会覆盖 *

* * @author jianggujin * */ @Retention(RUNTIME) @Target({ TYPE, METHOD, PARAMETER }) public @interface JRequestParam { /** * 请求参数信息 * * @return */ String value() default ""; /** * 请求参数每一项分隔字符串 * * @return */ String itemDelimiter() default "&"; /** * 请求参数的每一项的name/value分隔符 * * @return */ char kvDelimiter() default '='; /** * 是否必填 * * @return */ boolean required() default true; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy