Package com.azure.android.core.util
Class RequestContext
- java.lang.Object
-
- com.azure.android.core.util.RequestContext
-
public class RequestContext extends java.lang.Object
RequestContext
offers 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.NONE
ornull
.Each context object is immutable. The
addData(Object, Object)
method creates a newRequestContext
object that refers to its parent, forming a linked list.
-
-
Field Summary
Fields Modifier and Type Field Description static RequestContext
NONE
Signifies 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 newRequestContext
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestContext
addData(java.lang.Object key, java.lang.Object value)
Adds a new immutableRequestContext
object with the specified key-value pair to the existingRequestContext
chain.Option<java.lang.Object>
getData(java.lang.Object key)
Scans the linked-list ofRequestContext
objects 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 newRequestContext
object.- 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
- Ifkey
isnull
.
-
-
Method Detail
-
addData
public RequestContext addData(java.lang.Object key, java.lang.Object value)
Adds a new immutableRequestContext
object with the specified key-value pair to the existingRequestContext
chain.- 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
RequestContext
object containing the specified pair added to the set of pairs. - Throws:
java.lang.IllegalArgumentException
- Ifkey
isnull
.
-
getData
public Option<java.lang.Object> getData(java.lang.Object key)
Scans the linked-list ofRequestContext
objects 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
- Ifkey
isnull
.
-
-