Record Class ClientAddressResolver.ForwardedHeaders

java.lang.Object
java.lang.Record
com.iizix.server.geo.ip2location.ClientAddressResolver.ForwardedHeaders
Record Components:
forwarded - The Forwarded header values, never null.
xForwardedFor - The X-Forwarded-For header values, never null.
Enclosing class:
ClientAddressResolver

public static record ClientAddressResolver.ForwardedHeaders(List<String> forwarded, List<String> xForwardedFor) extends Record
The two forwarded-address headers of an HTTP upgrade request, in the order received.
Author:
Christopher Mindus
  • Field Details

  • Constructor Details

    • ForwardedHeaders

      public ForwardedHeaders(List<String> forwarded, List<String> xForwardedFor)
      Creates an instance of a ForwardedHeaders record class.
      Parameters:
      forwarded - the value for the forwarded record component
      xForwardedFor - the value for the xForwardedFor record component
  • Method Details

    • from

      public static ClientAddressResolver.ForwardedHeaders from(Map<String, List<String>> headerFields)
      Extracts the two headers from the header map of an upgrade request; header names are matched case-insensitively because the map carries them as sent.
      Parameters:
      headerFields - The header map, null for none.
      Returns:
      The headers, EMPTY when none is present.
    • isEmpty

      public boolean isEmpty()
      Returns if no header is present.
      Returns:
      true when both lists are empty.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • forwarded

      public List<String> forwarded()
      Returns the value of the forwarded record component.
      Returns:
      the value of the forwarded record component
    • xForwardedFor

      public List<String> xForwardedFor()
      Returns the value of the xForwardedFor record component.
      Returns:
      the value of the xForwardedFor record component