Annotation Type Attr


REST request attribute annotation.

Identifies a POJO retrieved from the request attributes map. Annotation that can be applied to a parameter of a @RestOp-annotated method to identify it as a value retrieved from the request attributes.

Example:

@RestGet public Person getPerson(@Attr("ETag") UUID etag) {...}

This is functionally equivalent to the following code...

@RestPost public void postPerson(RestRequest req, RestResponse res) { UUID etag = req.getAttributes().get(UUID.class, "ETag"); ... }

See Also:
  • Element Details

    • parser

      Specifies the HttpPartParser class used for parsing strings to values.

      Overrides for this part the part parser defined on the REST resource which by default is OpenApiParser.

      Returns:
      The annotation value.
      Default:
      org.apache.juneau.httppart.HttpPartParser.Void.class
    • name

      Request attribute name.

      The value should be either a valid attribute name, or "*" to represent multiple name/value pairs

      A blank value (the default) has the following behavior:

      • If the data type is NameValuePairs, Map, or a bean, then it's the equivalent to "*" which will cause the value to be serialized as name/value pairs.
        Examples:

        @RestPost("/addPet") public void addPet(@Attr JsonMap allAttributes) {...}

      Returns:
      The annotation value.
      Default:
      ""
    • value

      A synonym for name().

      Allows you to use shortened notation if you're only specifying the name.

      The following are completely equivalent ways of defining a header entry:

      public Order placeOrder(@Attr(name="api_key") String apiKey) {...}

      public Order placeOrder(@Attr("api_key") String apiKey) {...}

      Returns:
      The annotation value.
      Default:
      ""