Returns the top value of the Deque for the given TypedKey, without performing a pop. Note that this method will not block or throw an error if the Deque is empty. It will simply return the "Default Value" for the given TypeKey. Note null is a legal default value. @param key The TypeKey
(TypedKey<T> key)
| 101 | * @return The top value of the Deque for the given TypedKey |
| 102 | */ |
| 103 | public <T> T peek(TypedKey<T> key) |
| 104 | { |
| 105 | Deque<Object> dq = getDeque(Objects.requireNonNull(key)); |
| 106 | T value; |
| 107 | if ((dq == null) || dq.isEmpty()) |
| 108 | { |
| 109 | value = key.getDefaultValue(); |
| 110 | } |
| 111 | else |
| 112 | { |
| 113 | value = key.cast(unwrap(dq.peek())); |
| 114 | } |
| 115 | return value; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Sets a new value onto the Deque for the given TypedKey. |