@@ -96,6 +96,33 @@ public <T> Optional<T> getOrEmpty(Object key) {
9696 return Optional .ofNullable (t );
9797 }
9898
99+ /**
100+ * This returns true if the value at the specified key is equal to
101+ * {@link Boolean#TRUE}
102+ *
103+ * @param key the key to look up
104+ *
105+ * @return true if the value is equal to {@link Boolean#TRUE}
106+ */
107+ public Boolean getBoolean (Object key ) {
108+ Object val = map .get (assertNotNull (key ));
109+ return Boolean .TRUE .equals (val );
110+ }
111+
112+ /**
113+ * This returns true if the value at the specified key is equal to
114+ * {@link Boolean#TRUE} or the default value if the key is missing
115+ *
116+ * @param key the key to look up
117+ * @param defaultValue the value to use if the key is not present
118+ *
119+ * @return true if the value is equal to {@link Boolean#TRUE}
120+ */
121+ public Boolean getBoolean (Object key , Boolean defaultValue ) {
122+ Object val = map .getOrDefault (assertNotNull (key ), defaultValue );
123+ return Boolean .TRUE .equals (val );
124+ }
125+
99126 /**
100127 * Returns true if the context contains a value for that key
101128 *
@@ -177,11 +204,11 @@ public GraphQLContext putAll(Consumer<GraphQLContext.Builder> contextBuilderCons
177204 * Attempts to compute a mapping for the specified key and its
178205 * current mapped value (or null if there is no current mapping).
179206 *
180- * @param key key with which the specified value is to be associated
207+ * @param key key with which the specified value is to be associated
181208 * @param remappingFunction the function to compute a value
209+ * @param <T> for two
182210 *
183211 * @return the new value associated with the specified key, or null if none
184- * @param <T> for two
185212 */
186213 public <T > T compute (Object key , BiFunction <Object , ? super T , ? extends T > remappingFunction ) {
187214 assertNotNull (remappingFunction );
@@ -192,11 +219,11 @@ public <T> T compute(Object key, BiFunction<Object, ? super T, ? extends T> rema
192219 * If the specified key is not already associated with a value (or is mapped to null),
193220 * attempts to compute its value using the given mapping function and enters it into this map unless null.
194221 *
195- * @param key key with which the specified value is to be associated
222+ * @param key key with which the specified value is to be associated
196223 * @param mappingFunction the function to compute a value
224+ * @param <T> for two
197225 *
198226 * @return the current (existing or computed) value associated with the specified key, or null if the computed value is null
199- * @param <T> for two
200227 */
201228
202229 public <T > T computeIfAbsent (Object key , Function <Object , ? extends T > mappingFunction ) {
@@ -207,11 +234,11 @@ public <T> T computeIfAbsent(Object key, Function<Object, ? extends T> mappingFu
207234 * If the value for the specified key is present and non-null,
208235 * attempts to compute a new mapping given the key and its current mapped value.
209236 *
210- * @param key key with which the specified value is to be associated
237+ * @param key key with which the specified value is to be associated
211238 * @param remappingFunction the function to compute a value
239+ * @param <T> for two
212240 *
213241 * @return the new value associated with the specified key, or null if none
214- * @param <T> for two
215242 */
216243
217244 public <T > T computeIfPresent (Object key , BiFunction <Object , ? super T , ? extends T > remappingFunction ) {
0 commit comments