@@ -114,7 +114,7 @@ static Context detachFrom(Object carrier) {
114114 /**
115115 * Creates a copy of this context with the given key-value set.
116116 *
117- * <p>Existing value with the given key will be replaced, and mapping to a {@code null} value will
117+ * <p>Existing value with the given key will be replaced. Mapping to a {@code null} value will
118118 * remove the key-value from the context copy.
119119 *
120120 * @param <T> the type of the value.
@@ -124,6 +124,28 @@ static Context detachFrom(Object carrier) {
124124 */
125125 <T > Context with (ContextKey <T > key , @ Nullable T value );
126126
127+ /**
128+ * Creates a copy of this context with the given pair of key-values.
129+ *
130+ * <p>Existing values with the given keys will be replaced. Mapping to a {@code null} value will
131+ * remove the key-value from the context copy.
132+ *
133+ * @param <T> the type of the first value.
134+ * @param <U> the type of the second value.
135+ * @param firstKey the first key to store the first value.
136+ * @param firstValue the first value to store.
137+ * @param secondKey the second key to store the second value.
138+ * @param secondValue the second value to store.
139+ * @return a new context with the pair of key-values set.
140+ */
141+ default <T , U > Context with (
142+ ContextKey <T > firstKey ,
143+ @ Nullable T firstValue ,
144+ ContextKey <U > secondKey ,
145+ @ Nullable U secondValue ) {
146+ return with (firstKey , firstValue ).with (secondKey , secondValue );
147+ }
148+
127149 /**
128150 * Creates a copy of this context with the implicit key is mapped to the value.
129151 *
0 commit comments