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

io.github.pustike.web.FormParam Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2021 the original author or authors.
 *
 * 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
 *
 * https://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 io.github.pustike.web;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Binds the value(s) of a form parameter contained within a request entity body to a resource method parameter.
 * Values are URL decoded unless this is disabled using the {@link Encoded} annotation. A default value can be
 * specified using the {@link DefaultValue} annotation.
 * If the request entity body is absent or is an unsupported media type, the default value is used.
 *
 * The type {@code T} of the annotated parameter must either:
 * 
    *
  1. Be a primitive type
  2. *
  3. Have a constructor that accepts a single {@code String} argument
  4. *
  5. Have a static method named {@code valueOf} or {@code fromString} that accepts a single
  6. *
  7. Have a registered source to target type converter in {@link io.github.pustike.json.TypeConverter}
  8. *
  9. Be {@code List}, {@code Set} or {@code SortedSet}, where {@code T} satisfies 2, 3 or 4 above. * The resulting collection is read-only.
  10. *
* *

If the type is not one of the collection types listed in 5 above and the * form parameter is represented by multiple values then the first value (lexically) * of the parameter is used.

* *

Note that, whilst the annotation target permits use on fields and methods, * this annotation is only required to be supported on resource method parameters.

* * @see DefaultValue * @see Encoded */ @Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface FormParam { /** * Defines the name of the form parameter whose value will be used * to initialize the value of the annotated method argument. The name is * specified in decoded form, any percent encoded literals within the value * will not be decoded and will instead be treated as literal text. E.g. if * the parameter name is "a b" then the value of the annotation is "a b", * not "a+b" or "a%20b". * @return name of the form parameter */ String value(); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy