Class PartBeanMeta<T>

java.lang.Object
org.apache.juneau.http.part.PartBeanMeta<T>
Type Parameters:
T - The HTTP part bean type.

public class PartBeanMeta<T> extends Object
Holds metadata about http part beans (POJOs that get serialized as HTTP parts such as form data or query parameters).

HTTP part beans are typically annotated with @Query, @FormData, or @Path although it's not an absolute requirement.

HTTP part beans must have one of the following public constructors:

  • public X(String partValue)
  • public X(Object partValue)
  • public X(String partName, String partValue)
  • public X(String partName, Object partValue)

Example

// Our part bean. @Query("foo") public class FooPart extends BasicStringPart { public FooPart(String partValue) { super("foo", partValue); } } // Code to retrieve a part bean from a part list in a request. PartList parts = httpRequest.getFormDataList(); FooPart foo = parts.get(FooPart.class);

See Also:
  • Method Details

    • of

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

      Returns schema information about this part.

      This is information pulled from @Query, @FormData, or @Path annotations on the class.

      Returns:
      The schema information.
    • construct

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

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

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

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