UrlEncodedKeyValue.java

  1. package com.renomad.minum.web;

  2. import java.util.Objects;

  3. /**
  4.  * Represents a key-value pair with URL-encoding.
  5.  * This is the format of data when the Request is sent with a
  6.  * content-type header of application/x-www-form-urlencoded.
  7.  */
  8. public final class UrlEncodedKeyValue {
  9.     private final String key;
  10.     private final UrlEncodedDataGetter uedg;

  11.     public UrlEncodedKeyValue(String key, UrlEncodedDataGetter uedg) {
  12.         this.key = key;
  13.         this.uedg = uedg;
  14.     }

  15.     public String getKey() {
  16.         return key;
  17.     }

  18.     public UrlEncodedDataGetter getUedg() {
  19.         return uedg;
  20.     }

  21.     @Override
  22.     public boolean equals(Object o) {
  23.         if (this == o) return true;
  24.         if (o == null || getClass() != o.getClass()) return false;
  25.         UrlEncodedKeyValue that = (UrlEncodedKeyValue) o;
  26.         return Objects.equals(key, that.key) && Objects.equals(uedg, that.uedg);
  27.     }

  28.     @Override
  29.     public int hashCode() {
  30.         return Objects.hash(key, uedg);
  31.     }
  32. }