Class HeaderBeanMeta<T>

java.lang.Object
org.apache.juneau.http.header.HeaderBeanMeta<T>
Type Parameters:
T - The header bean type.

public class HeaderBeanMeta<T> extends Object
Holds metadata about header beans (POJOs that get serialized as HTTP headers).

Header beans are typically annotated with @Header although it's not an absolute requirement.

Header beans must have one of the following public constructors:

  • public X(String headerValue)
  • public X(Object headerValue)
  • public X(String headerName, String headerValue)
  • public X(String headerName, Object headerValue)

Example

// Our header bean. @Header("Foo") public class FooHeader extends BasicStringHeader { public FooHeader(String headerValue) { super("Foo", headerValue); } } // Code to retrieve a header bean from a header list in a request. HeaderList headers = httpRequest.getHeaders(); FooHeader foo = headers.get(FooHeader.class);

See Also:
  • Method Details

    • of

      public static <T> HeaderBeanMeta<T> of(Class<T> type)
      Finds the header bean meta for the specified type.
      Type Parameters:
      T - The header bean type.
      Parameters:
      type - The header bean type.
      Returns:
      The metadata, or null if a valid constructor could not be found.
    • getSchema

      Returns schema information about this header.

      This is information pulled from @Header annotation on the class.

      Returns:
      The schema information.
    • construct

      public T construct(Object value)
      Constructs a header bean with the specified name or value.

      Can only be used on beans where the header name is known.

      Parameters:
      value - The header value.
      Returns:
      A newly constructed bean.
    • construct

      public T construct(String name, Object value)
      Constructs a header bean with the specified name or value.
      Parameters:
      name - The header name.
      If null, uses the value pulled from the @Header(name) or @Header(value) annotations.
      value - The header value.
      Returns:
      A newly constructed bean.
      Throws:
      UnsupportedOperationException - If bean could not be constructed (e.g. couldn't find a constructor).