Package com.azure.android.core.util
Class RequestContext
- java.lang.Object
-
- com.azure.android.core.util.RequestContext
-
public class RequestContext extends java.lang.ObjectRequestContextoffers a means of passing arbitrary data (key-value pairs) to pipeline policies. Most applications do not need to pass arbitrary data to the pipeline and can passRequestContext.NONEornull.Each context object is immutable. The
addData(Object, Object)method creates a newRequestContextobject that refers to its parent, forming a linked list.
-
-
Field Summary
Fields Modifier and Type Field Description static RequestContextNONESignifies that no data needs to be passed to the pipeline.
-
Constructor Summary
Constructors Constructor Description RequestContext(java.lang.Object key, java.lang.Object value)Constructs a newRequestContextobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestContextaddData(java.lang.Object key, java.lang.Object value)Adds a new immutableRequestContextobject with the specified key-value pair to the existingRequestContextchain.Option<java.lang.Object>getData(java.lang.Object key)Scans the linked-list ofRequestContextobjects looking for one with the specified key.
-
-
-
Field Detail
-
NONE
public static final RequestContext NONE
Signifies that no data needs to be passed to the pipeline.
-
-
Constructor Detail
-
RequestContext
public RequestContext(java.lang.Object key, java.lang.Object value)Constructs a newRequestContextobject.- Parameters:
key- The key with which the specified value should be associated.value- The value to be associated with the specified key.- Throws:
java.lang.IllegalArgumentException- Ifkeyisnull.
-
-
Method Detail
-
addData
public RequestContext addData(java.lang.Object key, java.lang.Object value)
Adds a new immutableRequestContextobject with the specified key-value pair to the existingRequestContextchain.- Parameters:
key- The key with which the specified value should be associated.value- The value to be associated with the specified key.- Returns:
- the new
RequestContextobject containing the specified pair added to the set of pairs. - Throws:
java.lang.IllegalArgumentException- Ifkeyisnull.
-
getData
public Option<java.lang.Object> getData(java.lang.Object key)
Scans the linked-list ofRequestContextobjects looking for one with the specified key. Note that the first key found, i.e. the most recently added, will be returned.- Parameters:
key- The key to search for.- Returns:
- The value of the specified key if it exists.
- Throws:
java.lang.IllegalArgumentException- Ifkeyisnull.
-
-