Record Class ContentView.Metadata

java.lang.Object
java.lang.Record
org.microproxy.contentviews.ContentView.Metadata
Record Components:
contentType - the Content-Type field, or null
headers - the message's header fields (never null)
trailers - the message's trailer fields (never null)
path - the request's path and query (for a response, its request's), or null; an absolute URI is reduced to its path and query
request - whether the body is a request's
Enclosing interface:
ContentView

public static record ContentView.Metadata(String contentType, HttpHeaders headers, HttpHeaders trailers, String path, boolean request) extends Record
What a view knows about a body besides its bytes.
  • Constructor Details

    • Metadata

      public Metadata(String contentType, HttpHeaders headers, HttpHeaders trailers, String path, boolean request)
      Fills in empty header fields for null, and reduces an absolute URI to its path.
      Parameters:
      contentType - the Content-Type field, or null
      headers - the header fields, or null
      trailers - the trailer fields, or null
      path - the request's path and query, or null
      request - whether the body is a request's
  • Method Details

    • of

      public static ContentView.Metadata of(String contentType)
      Metadata with only a content type.
      Parameters:
      contentType - the Content-Type field, or null
      Returns:
      the metadata
    • forRequest

      public static ContentView.Metadata forRequest(HttpRequest request)
      Metadata for a request's body.
      Parameters:
      request - the request
      Returns:
      the metadata
    • forResponse

      public static ContentView.Metadata forResponse(HttpRequest request, HttpMessage response)
      Metadata for a response's body.
      Parameters:
      request - the request the response answers, or null
      response - the response (or any message)
      Returns:
      the metadata
    • withTrailers

      public ContentView.Metadata withTrailers(HttpHeaders trailers)
      This metadata with trailer fields.
      Parameters:
      trailers - the trailer fields
      Returns:
      new metadata
    • withPath

      public ContentView.Metadata withPath(String path)
      This metadata with a request path.
      Parameters:
      path - the request's path and query, or null
      Returns:
      new metadata
    • mediaType

      public String mediaType()
      Returns the media type of contentType in lower case, without parameters, or "".
      Returns:
      the media type of contentType in lower case, without parameters, or ""
    • parameter

      public String parameter(String name)
      A parameter of contentType, such as boundary or charset.
      Parameters:
      name - the parameter's name (any case)
      Returns:
      its value without quotes, or null
    • header

      public String header(String name)
      A header field's first value.
      Parameters:
      name - the field name (any case)
      Returns:
      the value, or null
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • contentType

      public String contentType()
      Returns the value of the contentType record component.
      Returns:
      the value of the contentType record component
    • headers

      public HttpHeaders headers()
      Returns the value of the headers record component.
      Returns:
      the value of the headers record component
    • trailers

      public HttpHeaders trailers()
      Returns the value of the trailers record component.
      Returns:
      the value of the trailers record component
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • request

      public boolean request()
      Returns the value of the request record component.
      Returns:
      the value of the request record component