MCPcopy Create free account
hub / github.com/PCGen/pcgen / peek

Method peek

PCGen-base/code/src/java/pcgen/base/util/MappedDeque.java:103–116  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 4

testNonNullKeyMethod · 0.95
testPushPopPeekMethod · 0.95
testSetMethod · 0.95
nextMethod · 0.45

Calls 5

getDequeMethod · 0.95
unwrapMethod · 0.95
isEmptyMethod · 0.65
getDefaultValueMethod · 0.65
castMethod · 0.45

Tested by 3

testNonNullKeyMethod · 0.76
testPushPopPeekMethod · 0.76
testSetMethod · 0.76