Skip to content

Instantly share code, notes, and snippets.

@nsivabalan
Last active October 28, 2020 19:52
Show Gist options
  • Save nsivabalan/ffff6bb1539b9254c4355e3a8c5e1f1f to your computer and use it in GitHub Desktop.
Save nsivabalan/ffff6bb1539b9254c4355e3a8c5e1f1f to your computer and use it in GitHub Desktop.
/**
* Interface representing Request/Response headers. This is a common interface for all network
* transports and each transport is expected to have its own implementation.
*
* @param <T> represents the actual transport header object of generic type T.
*/
public interface UberCallHeaders<T> {
/**
* Fetch value corresponding to the given key.
*
* @param key key for which value is expected.
* @return the value if found. else {@code null}.
*/
@Nullable
String getHeaderValue(String key);
/**
* Sets the value for the respective header in the {@link UberNetworkHeaders} object.
*
* @param key key of interest.
* @param value value to be set for the passed in key.
*/
void setHeader(String key, String value);
/**
* Removes the entry from {@link UberNetworkHeaders} if present.
*
* @param key the key for which entry needs to be removed.
* @return true if the value is present and removed. else false.
*/
boolean removeHeaderValue(String key);
/** @return all keys as a {@link Set} of strings. */
Set<String> getAllHeaderKeys();
/** @return entire set of headers as a {@link Map} of key(string) to value(string) */
Map<String, String> getHeadersAsMap();
/** @return the networkTransport headers object instance. */
T getNetworkTransportHeaders();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment